Fix compiler warnings in modular build
Fixed all compiler warnings from the modular build: 1. src/device.c:82 - Changed info array from 'unsigned char' to 'char' to match strlen() and strcmp() parameter types 2. src/device.c:365 - Changed loop variable from 'int' to 'size_t' to match sizeof() return type 3. src/compat.c:20 - Increased path buffer from 256 to 512 bytes to prevent potential truncation with long directory names Build now compiles cleanly with -Wall -Wextra -Wpedantic flags.
+3 −3 · 2 files changed
-
src/compat.c+1 −1 -
src/device.c+2 −2
@@ -17,7 +17,7 @@ int is_module_loaded(const char* module_name) { int try_hidraw_access(void) { DIR *dir; struct dirent *ent; - char path[256]; + char path[512]; char buf[256]; dir = opendir("/dev"); @@ -79,7 +79,7 @@ void device_run(libusb_context* ctx, config_t* config, int debug, int accept, in while ((dev = devs[d++]) != NULL) { struct libusb_device_descriptor devDesc; - unsigned char info[200] = ""; + char info[200] = ""; err = libusb_get_device_descriptor(dev, &devDesc); if (err < 0) { @@ -362,7 +362,7 @@ void device_run(libusb_context* ctx, config_t* config, int debug, int accept, in if (debug == 2 || dry) { printf("DATA: [%d", data[0]); - for (int i = 1; i < sizeof(data); i++) { + for (size_t i = 1; i < sizeof(data); i++) { printf(", %d", data[i]); } printf("]\n");