diff options
author | Lennart Poettering <lennart@poettering.net> | 2008-08-19 22:39:54 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2008-08-19 22:39:54 +0200 |
commit | b7026bf248948a6a30386ddbcc137f48f369a51e (patch) | |
tree | 0941ba3f61298fd9b8cb5b34fc236248519b0c8f /src/tests | |
parent | 047eb52b521a61aef54bd1760b5470a963ea47b6 (diff) |
add a few more gcc warning flags and fix quite a few problems found by doing so
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/envelope-test.c | 12 | ||||
-rw-r--r-- | src/tests/mcalign-test.c | 8 | ||||
-rw-r--r-- | src/tests/mix-test.c | 20 | ||||
-rw-r--r-- | src/tests/pacat-simple.c | 2 | ||||
-rw-r--r-- | src/tests/parec-simple.c | 5 | ||||
-rw-r--r-- | src/tests/resampler-test.c | 20 | ||||
-rw-r--r-- | src/tests/rtstutter.c | 14 | ||||
-rw-r--r-- | src/tests/smoother-test.c | 2 | ||||
-rw-r--r-- | src/tests/stripnul.c | 6 | ||||
-rw-r--r-- | src/tests/sync-playback.c | 2 |
10 files changed, 47 insertions, 44 deletions
diff --git a/src/tests/envelope-test.c b/src/tests/envelope-test.c index 9f914553..d71eff1c 100644 --- a/src/tests/envelope-test.c +++ b/src/tests/envelope-test.c @@ -40,7 +40,7 @@ const pa_envelope_def ramp_down = { .n_points = 2, .points_x = { 100*PA_USEC_PER_MSEC, 300*PA_USEC_PER_MSEC }, .points_y = { - .f = { 1.0, 0.2 }, + .f = { 1.0f, 0.2f }, .i = { 0x10000, 0x10000/5 } } }; @@ -49,7 +49,7 @@ const pa_envelope_def ramp_up = { .n_points = 2, .points_x = { 100*PA_USEC_PER_MSEC, 300*PA_USEC_PER_MSEC }, .points_y = { - .f = { 0.2, 1.0 }, + .f = { 0.2f, 1.0f }, .i = { 0x10000/5, 0x10000 } } }; @@ -58,7 +58,7 @@ const pa_envelope_def ramp_down2 = { .n_points = 2, .points_x = { 50*PA_USEC_PER_MSEC, 900*PA_USEC_PER_MSEC }, .points_y = { - .f = { 0.8, 0.7 }, + .f = { 0.8f, 0.7f }, .i = { 0x10000*4/5, 0x10000*7/10 } } }; @@ -67,7 +67,7 @@ const pa_envelope_def ramp_up2 = { .n_points = 2, .points_x = { 50*PA_USEC_PER_MSEC, 900*PA_USEC_PER_MSEC }, .points_y = { - .f = { 0.7, 0.9 }, + .f = { 0.7f, 0.9f }, .i = { 0x10000*7/10, 0x10000*9/10 } } }; @@ -140,7 +140,7 @@ static pa_memblock * generate_block(pa_mempool *pool, const pa_sample_spec *ss) unsigned n_samples; block = pa_memblock_new(pool, pa_bytes_per_second(ss)); - n_samples = pa_memblock_get_length(block) / pa_sample_size(ss); + n_samples = (unsigned) (pa_memblock_get_length(block) / pa_sample_size(ss)); d = pa_memblock_acquire(block); @@ -171,7 +171,7 @@ static pa_memblock * generate_block(pa_mempool *pool, const pa_sample_spec *ss) float *f; for (f = d; n_samples > 0; n_samples--, f++) - *f = PA_MAYBE_FLOAT32_SWAP(ss->format == PA_SAMPLE_FLOAT32RE, 1.0); + *f = PA_MAYBE_FLOAT32_SWAP(ss->format == PA_SAMPLE_FLOAT32RE, 1.0f); break; } diff --git a/src/tests/mcalign-test.c b/src/tests/mcalign-test.c index e23f098c..c0665822 100644 --- a/src/tests/mcalign-test.c +++ b/src/tests/mcalign-test.c @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) { pa_memchunk_reset(&c); - srand(time(NULL)); + srand((unsigned) time(NULL)); for (;;) { ssize_t r; @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) { l = pa_memblock_get_length(c.memblock) - c.index; - l = l <= 1 ? l : rand() % (l-1) +1 ; + l = l <= 1 ? l : (size_t) rand() % (l-1) +1; p = pa_memblock_acquire(c.memblock); @@ -74,11 +74,11 @@ int main(int argc, char *argv[]) { pa_memblock_release(c.memblock); - c.length = r; + c.length = (size_t) r; pa_mcalign_push(a, &c); fprintf(stderr, "Read %ld bytes\n", (long)r); - c.index += r; + c.index += (size_t) r; if (c.index >= pa_memblock_get_length(c.memblock)) { pa_memblock_unref(c.memblock); diff --git a/src/tests/mix-test.c b/src/tests/mix-test.c index f3f6f829..544121fd 100644 --- a/src/tests/mix-test.c +++ b/src/tests/mix-test.c @@ -166,16 +166,16 @@ static pa_memblock* generate_block(pa_mempool *pool, const pa_sample_spec *ss) { case PA_SAMPLE_FLOAT32RE: { float *u = d; - u[0] = 0.0; - u[1] = -1.0; - u[2] = 1.0; - u[3] = 4711; - u[4] = 0.222; - u[5] = 0.33; - u[6] = -.3; - u[7] = 99; - u[8] = -0.555; - u[9] = -.123; + u[0] = 0.0f; + u[1] = -1.0f; + u[2] = 1.0f; + u[3] = 4711.0f; + u[4] = 0.222f; + u[5] = 0.33f; + u[6] = -.3f; + u[7] = 99.0f; + u[8] = -0.555f; + u[9] = -.123f; if (ss->format == PA_SAMPLE_FLOAT32RE) for (i = 0; i < 10; i++) diff --git a/src/tests/pacat-simple.c b/src/tests/pacat-simple.c index ed54f57d..ffe3176a 100644 --- a/src/tests/pacat-simple.c +++ b/src/tests/pacat-simple.c @@ -94,7 +94,7 @@ int main(int argc, char*argv[]) { } /* ... and play it */ - if (pa_simple_write(s, buf, r, &error) < 0) { + if (pa_simple_write(s, buf, (size_t) r, &error) < 0) { fprintf(stderr, __FILE__": pa_simple_write() failed: %s\n", pa_strerror(error)); goto finish; } diff --git a/src/tests/parec-simple.c b/src/tests/parec-simple.c index ea34a075..0312005d 100644 --- a/src/tests/parec-simple.c +++ b/src/tests/parec-simple.c @@ -47,7 +47,7 @@ static ssize_t loop_write(int fd, const void*data, size_t size) { ret += r; data = (const uint8_t*) data + r; - size -= r; + size -= (size_t) r; } return ret; @@ -80,6 +80,9 @@ int main(int argc, char*argv[]) { goto finish; } + if (r == 0) + break; + /* And write it to STDOUT */ if ((r = loop_write(STDOUT_FILENO, buf, sizeof(buf))) <= 0) { fprintf(stderr, __FILE__": write() failed: %s\n", strerror(errno)); diff --git a/src/tests/resampler-test.c b/src/tests/resampler-test.c index 1a20be2c..6959127b 100644 --- a/src/tests/resampler-test.c +++ b/src/tests/resampler-test.c @@ -166,16 +166,16 @@ static pa_memblock* generate_block(pa_mempool *pool, const pa_sample_spec *ss) { case PA_SAMPLE_FLOAT32RE: { float *u = d; - u[0] = 0.0; - u[1] = -1.0; - u[2] = 1.0; - u[3] = 4711; - u[4] = 0.222; - u[5] = 0.33; - u[6] = -.3; - u[7] = 99; - u[8] = -0.555; - u[9] = -.123; + u[0] = 0.0f; + u[1] = -1.0f; + u[2] = 1.0f; + u[3] = 4711.0f; + u[4] = 0.222f; + u[5] = 0.33f; + u[6] = -.3f; + u[7] = 99.0f; + u[8] = -0.555f; + u[9] = -.123f; if (ss->format == PA_SAMPLE_FLOAT32RE) for (i = 0; i < 10; i++) diff --git a/src/tests/rtstutter.c b/src/tests/rtstutter.c index 91e85c36..6b0cb8f7 100644 --- a/src/tests/rtstutter.c +++ b/src/tests/rtstutter.c @@ -52,7 +52,7 @@ static void* work(void *p) { pa_assert_se(pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) == 0); CPU_ZERO(&mask); - CPU_SET(PA_PTR_TO_INT(p), &mask); + CPU_SET((size_t) PA_PTR_TO_INT(p), &mask); pa_assert_se(pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) == 0); for (;;) { @@ -65,17 +65,17 @@ static void* work(void *p) { pa_assert_se(clock_gettime(CLOCK_REALTIME, &end) == 0); nsec = - (uint64_t) ((((double) rand())*(msec_upper-msec_lower)*PA_NSEC_PER_MSEC)/RAND_MAX) + - (uint64_t) (msec_lower*PA_NSEC_PER_MSEC); + (uint64_t) ((((double) rand())*(double)(msec_upper-msec_lower)*PA_NSEC_PER_MSEC)/RAND_MAX) + + (uint64_t) ((uint64_t) msec_lower*PA_NSEC_PER_MSEC); pa_log_notice("CPU%i: Freezing for %ims", PA_PTR_TO_INT(p), (int) (nsec/PA_NSEC_PER_MSEC)); - end.tv_sec += nsec / PA_NSEC_PER_SEC; - end.tv_nsec += nsec % PA_NSEC_PER_SEC; + end.tv_sec += (time_t) (nsec / PA_NSEC_PER_SEC); + end.tv_nsec += (long int) (nsec % PA_NSEC_PER_SEC); while ((pa_usec_t) end.tv_nsec > PA_NSEC_PER_SEC) { end.tv_sec++; - end.tv_nsec -= PA_NSEC_PER_SEC; + end.tv_nsec -= (long int) PA_NSEC_PER_SEC; } do { @@ -88,7 +88,7 @@ static void* work(void *p) { int main(int argc, char*argv[]) { int n; - srand(time(NULL)); + srand((unsigned) time(NULL)); if (argc >= 3) { msec_lower = atoi(argv[1]); diff --git a/src/tests/smoother-test.c b/src/tests/smoother-test.c index b78f3c91..15700ec2 100644 --- a/src/tests/smoother-test.c +++ b/src/tests/smoother-test.c @@ -64,7 +64,7 @@ int main(int argc, char*argv[]) { for (x = 0, u = 0; x < PA_USEC_PER_SEC * 10; x += PA_USEC_PER_MSEC) { while (u < PA_ELEMENTSOF(msec) && (pa_usec_t) msec[u]*PA_USEC_PER_MSEC < x) { - pa_smoother_put(s, msec[u]*PA_USEC_PER_MSEC, msec[u+1]*PA_USEC_PER_MSEC); + pa_smoother_put(s, (pa_usec_t) msec[u] * PA_USEC_PER_MSEC, (pa_usec_t) msec[u+1] * PA_USEC_PER_MSEC); printf("%i\t\t%i\n", msec[u], msec[u+1]); u += 2; } diff --git a/src/tests/stripnul.c b/src/tests/stripnul.c index 0ab06776..2b8aa083 100644 --- a/src/tests/stripnul.c +++ b/src/tests/stripnul.c @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) { uint8_t *zero; pa_assert_se(argc >= 2); - pa_assert_se((granularity = atoi(argv[1])) >= 1); + pa_assert_se((granularity = (size_t) atoi(argv[1])) >= 1); pa_assert_se((i = (argc >= 3) ? fopen(argv[2], "r") : stdin)); pa_assert_se((o = (argc >= 4) ? fopen(argv[3], "w") : stdout)); @@ -53,11 +53,11 @@ int main(int argc, char *argv[]) { if (found) pa_assert_se(fwrite(buffer, granularity, k, o) == k); else { - for (p = buffer; (p-buffer)/granularity < k; p += granularity) + for (p = buffer; ((size_t) (p-buffer)/granularity) < k; p += granularity) if (memcmp(p, zero, granularity)) { size_t left; found = TRUE; - left = k - (p-buffer)/granularity; + left = (size_t) (k - (size_t) (p-buffer)/granularity); pa_assert_se(fwrite(p, granularity, left, o) == left); break; } diff --git a/src/tests/sync-playback.c b/src/tests/sync-playback.c index 7e364685..42c479a1 100644 --- a/src/tests/sync-playback.c +++ b/src/tests/sync-playback.c @@ -89,7 +89,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) { fprintf(stderr, "Writing data to stream %i.\n", i); - r = pa_stream_write(s, data, sizeof(data), nop_free_cb, sizeof(data) * i, PA_SEEK_ABSOLUTE); + r = pa_stream_write(s, data, sizeof(data), nop_free_cb, (int64_t) sizeof(data) * (int64_t) i, PA_SEEK_ABSOLUTE); assert(r == 0); /* Be notified when this stream is drained */ |