Skip to content

Commit 69c222f

Browse files
authored
Merge pull request #80 from JHartzer/static-analysis
Static analysis
2 parents 5531d3e + 5858600 commit 69c222f

5 files changed

Lines changed: 16 additions & 11 deletions

File tree

blink1-lib.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define strcasecmp _stricmp // POSIX; MSVC equivalent is _stricmp
2121
#else
2222
#include <unistd.h>
23+
#include <strings.h>
2324
#endif
2425

2526
#include "blink1-lib.h"
@@ -157,7 +158,7 @@ blink1Type_t blink1_deviceTypeById( int i )
157158
return blink1_infos[i].type;
158159
}
159160

160-
// returns BLINK1_MK1, BLINK1_MK2, BLINK1_MK3, or BLINK1_MK4
161+
// returns BLINK1_MK1, BLINK1_MK2, BLINK1_MK3, or BLINK1_MK4
161162
blink1Type_t blink1_deviceType( blink1_device* dev )
162163
{
163164
return blink1_deviceTypeById( blink1_getCacheIndexByDev(dev) );
@@ -190,7 +191,7 @@ int blink1_isMk2( blink1_device* dev )
190191
return blink1_isMk2ById( blink1_getCacheIndexByDev(dev) );
191192
}
192193

193-
const int blink1_getPattMax(blink1_device* dev) {
194+
int blink1_getPattMax(blink1_device* dev) {
194195
return blink1_pattMaxes[blink1_deviceType(dev)];
195196
}
196197

@@ -854,7 +855,7 @@ int parsePattern(char* pattstr, int* repeats, patternline_t* pattern)
854855
{
855856
char str[1000];
856857
sprintf(str, "%s", pattstr); // FIXME: check size
857-
858+
858859
remove_whitespace(str);
859860
char* s;
860861
s = strtok( str, ", ");

blink1-lib.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ typedef struct hid_device_ blink1_device; /* opaque blink1 structure */
7676

7777
// Set blink1_lib_verbose to 1 to enable low-level debugging
7878
extern int blink1_lib_verbose;
79-
79+
8080
typedef struct {
8181
uint8_t r; uint8_t g; uint8_t b;
8282
} rgb_t;
@@ -523,9 +523,9 @@ blink1Type_t blink1_deviceType( blink1_device* dev );
523523
const char* blink1_deviceTypeToStr(blink1Type_t t);
524524

525525

526-
const int blink1_getPattMax(blink1_device* dev);
527-
528-
526+
int blink1_getPattMax(blink1_device* dev);
527+
528+
529529
/**
530530
* Take an array of bytes and spit them out as a hex string to fp
531531
*/
@@ -565,7 +565,7 @@ int parsePattern( char* str, int* repeats, patternline_t* pattern );
565565
* Returns length of string created
566566
*/
567567
int toPatternString(patternline_t* pattern, int pattlen, int repeats, char* pattstr);
568-
568+
569569
/**
570570
* printf that can be shut up
571571
*

blink1-tool.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
*/
1212

1313
#include <stdio.h>
14-
#include <stdarg.h> // vararg stuff
1514
#include <string.h> // for memset(), strcmp(), et al
1615
#include <stdlib.h>
1716
#include <stdint.h>

blink1control-tool/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ CFLAGS += -DBLINK1_VERSION=\"$(BLINK1_VERSION)\"
109109

110110
CFLAGS += -lm
111111
# to fix usleep() not being found on Ubuntu14
112-
CFLAGS += -D_BSD_SOURCE
112+
CFLAGS += -D_DEFAULT_SOURCE
113113

114114
CFLAGS += -Wno-pointer-to-int-cast
115115
CFLAGS += -I json-parser

server/blink1-tiny-server.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@
2121
*/
2222

2323
#include <getopt.h> // for getopt_long_only()
24-
#include <sys/time.h>
2524
#include <signal.h>
25+
#include <stdbool.h>
26+
#include <stdint.h>
2627
#include <stdio.h>
28+
#include <stdlib.h>
29+
#include <string.h>
30+
#include <time.h>
31+
#include <unistd.h>
2732

2833
#include "mongoose.h" // HTTP server
2934
#include "parson.h" // JSON build and parse

0 commit comments

Comments
 (0)