git ssb

0+

cel / foostudio



Commit 2b3308729b9a63d56cc2c4712e8bab2aa818a492

Cleanup some code

- Avoid signed-unsigned comparisons
- Remove unused variables
- Rebuild after updating makefile
- Rename mktemp function
cel committed on 10/24/2016, 11:52:20 PM
Parent: b5ebb2a607ac9ea92f525350e5b18580d0e71888

Files changed

Makefilechanged
ccdl.cchanged
studio.cchanged
MakefileView
@@ -1,8 +1,10 @@
1-CFLAGS = -std=c99
1 +CFLAGS = -Wall -Wextra -pedantic
22 LDLIBS = -ldl -lasound -lm -lpthread
33
44 studio: studio.o ccdl.o
55
6 +studio.o ccdl.o: Makefile
7 +
68 clean:
79 $(RM) *.o *.so studio
810
ccdl.cView
@@ -11,9 +11,9 @@
1111 #include "ccdl.h"
1212
1313 static unsigned int tmp_i = 0;
1414
15-static const char *mktemp()
15 +static const char *my_mktemp()
1616 {
1717 const char *tmpdir = getenv("TMPDIR");
1818 if (!tmpdir) tmpdir = "/tmp";
1919 static char buf[256];
@@ -61,9 +61,9 @@
6161 const char *lib_fname = lib->lib_fname;
6262 if (!lib_fname) {
6363 const char *src_fname = lib->src_fname;
6464 if (!src_fname) return -1;
65- lib_fname = mktemp();
65 + lib_fname = my_mktemp();
6666 if (!lib_fname) return -1;
6767 lib->lib_fname = lib_fname;
6868 if (compile(src_fname, lib_fname)) return -1;
6969 }
@@ -143,9 +143,9 @@
143143 if (len < 0) {
144144 warn("read");
145145 return -1;
146146 }
147- if (len < sizeof ev) {
147 + if ((size_t)len < sizeof ev) {
148148 warn("small read");
149149 continue;
150150 }
151151 if (ev.len > 0) {
@@ -185,11 +185,9 @@
185185 }
186186
187187 int ccdl_rebuild(struct ccdl *ccdl)
188188 {
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);
192190 lib_deinit(new_lib);
193191 if (lib_build(new_lib) < 0) return -1;
194192 ccdl->lib = new_lib;
195193 return 0;
studio.cView
@@ -50,9 +50,9 @@
5050 unsigned char *samples[channels];
5151 int steps[channels];
5252 unsigned int chn;
5353 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;
5555 int bps = format_bits / 8; /* bytes per sample */
5656 int phys_bps = snd_pcm_format_physical_width(format) / 8;
5757 int big_endian = snd_pcm_format_big_endian(format) == 1;
5858 int to_unsigned = snd_pcm_format_unsigned(format) == 1;
@@ -180,9 +180,9 @@
180180 }
181181 first = 1;
182182 continue;
183183 }
184- if (avail < period_size) {
184 + if ((snd_pcm_uframes_t)avail < period_size) {
185185 if (first) {
186186 first = 0;
187187 err = snd_pcm_start(pcm_out);
188188 if (err < 0) {

Built with git-ssb-web