Commit 2b3308729b9a63d56cc2c4712e8bab2aa818a492
Cleanup some code
- Avoid signed-unsigned comparisons - Remove unused variables - Rebuild after updating makefile - Rename mktemp functioncel committed on 10/24/2016, 11:52:20 PM
Parent: b5ebb2a607ac9ea92f525350e5b18580d0e71888
Files changed
Makefile | changed |
ccdl.c | changed |
studio.c | changed |
Makefile | ||
---|---|---|
@@ -1,8 +1,10 @@ | ||
1 | -CFLAGS = -std=c99 | |
1 … | +CFLAGS = -Wall -Wextra -pedantic | |
2 | 2 … | LDLIBS = -ldl -lasound -lm -lpthread |
3 | 3 … | |
4 | 4 … | studio: studio.o ccdl.o |
5 | 5 … | |
6 … | +studio.o ccdl.o: Makefile | |
7 … | + | |
6 | 8 … | clean: |
7 | 9 … | $(RM) *.o *.so studio |
8 | 10 … |
ccdl.c | |||
---|---|---|---|
@@ -11,9 +11,9 @@ | |||
11 | 11 … | ||
12 | 12 … | ||
13 | 13 … | static unsigned int tmp_i = 0; | |
14 | 14 … | ||
15 | -static const char *mktemp() | ||
15 … | +static const char *my_mktemp() | ||
16 | 16 … | { | |
17 | 17 … | const char *tmpdir = getenv("TMPDIR"); | |
18 | 18 … | if (!tmpdir) tmpdir = "/tmp"; | |
19 | 19 … | static char buf[256]; | |
@@ -61,9 +61,9 @@ | |||
61 | 61 … | const char *lib_fname = lib->lib_fname; | |
62 | 62 … | if (!lib_fname) { | |
63 | 63 … | const char *src_fname = lib->src_fname; | |
64 | 64 … | if (!src_fname) return -1; | |
65 | - lib_fname = mktemp(); | ||
65 … | + lib_fname = my_mktemp(); | ||
66 | 66 … | if (!lib_fname) return -1; | |
67 | 67 … | lib->lib_fname = lib_fname; | |
68 | 68 … | if (compile(src_fname, lib_fname)) return -1; | |
69 | 69 … | } | |
@@ -143,9 +143,9 @@ | |||
143 | 143 … | if (len < 0) { | |
144 | 144 … | warn("read"); | |
145 | 145 … | return -1; | |
146 | 146 … | } | |
147 | - if (len < sizeof ev) { | ||
147 … | + if ((size_t)len < sizeof ev) { | ||
148 | 148 … | warn("small read"); | |
149 | 149 … | continue; | |
150 | 150 … | } | |
151 | 151 … | if (ev.len > 0) { | |
@@ -185,11 +185,9 @@ | |||
185 | 185 … | } | |
186 | 186 … | ||
187 | 187 … | int ccdl_rebuild(struct ccdl *ccdl) | |
188 | 188 … | { | |
189 | - struct lib *old_lib, *new_lib; | ||
190 | - old_lib = ccdl->lib; | ||
191 | - new_lib = ccdl_get_old_lib(ccdl); | ||
189 … | + struct lib *new_lib = ccdl_get_old_lib(ccdl); | ||
192 | 190 … | lib_deinit(new_lib); | |
193 | 191 … | if (lib_build(new_lib) < 0) return -1; | |
194 | 192 … | ccdl->lib = new_lib; | |
195 | 193 … | return 0; |
studio.c | ||
---|---|---|
@@ -50,9 +50,9 @@ | ||
50 | 50 … | unsigned char *samples[channels]; |
51 | 51 … | int steps[channels]; |
52 | 52 … | unsigned int chn; |
53 | 53 … | int format_bits = snd_pcm_format_width(format); |
54 | - unsigned int maxval = (1 << (format_bits - 1)) - 1; | |
54 … | + // unsigned int maxval = (1 << (format_bits - 1)) - 1; | |
55 | 55 … | int bps = format_bits / 8; /* bytes per sample */ |
56 | 56 … | int phys_bps = snd_pcm_format_physical_width(format) / 8; |
57 | 57 … | int big_endian = snd_pcm_format_big_endian(format) == 1; |
58 | 58 … | int to_unsigned = snd_pcm_format_unsigned(format) == 1; |
@@ -180,9 +180,9 @@ | ||
180 | 180 … | } |
181 | 181 … | first = 1; |
182 | 182 … | continue; |
183 | 183 … | } |
184 | - if (avail < period_size) { | |
184 … | + if ((snd_pcm_uframes_t)avail < period_size) { | |
185 | 185 … | if (first) { |
186 | 186 … | first = 0; |
187 | 187 … | err = snd_pcm_start(pcm_out); |
188 | 188 … | if (err < 0) { |
Built with git-ssb-web