From b8d1d0c3fc27e563273a0c6d0a10ebe673ea2904 Mon Sep 17 00:00:00 2001 From: Florian Franzmann Date: Sat, 5 Sep 2020 16:33:08 +0200 Subject: [PATCH] Cleanup: Improve const correctness --- culfw.c | 2 +- culfw.h | 2 +- hexdump.h | 4 ++-- hmcfgusb.c | 4 ++-- hmland.c | 2 +- hmsniff.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/culfw.c b/culfw.c index 34d3eba..99b20cb 100644 --- a/culfw.c +++ b/culfw.c @@ -110,7 +110,7 @@ out: return NULL; } -int culfw_send(struct culfw_dev *dev, char *cmd, int cmdlen) +int culfw_send(struct culfw_dev *dev, const char *cmd, int cmdlen) { int w = 0; int ret; diff --git a/culfw.h b/culfw.h index bbe64f5..9c98eb7 100644 --- a/culfw.h +++ b/culfw.h @@ -32,7 +32,7 @@ struct culfw_dev { }; struct culfw_dev *culfw_init(char *device, uint32_t speed, culfw_cb_fn cb, void *data); -int culfw_send(struct culfw_dev *dev, char *cmd, int cmdlen); +int culfw_send(struct culfw_dev *dev, const char *cmd, int cmdlen); int culfw_poll(struct culfw_dev *dev, int timeout); void culfw_close(struct culfw_dev *dev); void culfw_flush(struct culfw_dev *dev); diff --git a/hexdump.h b/hexdump.h index d3d4f3b..127bfb0 100644 --- a/hexdump.h +++ b/hexdump.h @@ -21,7 +21,7 @@ * IN THE SOFTWARE. */ -static void asciishow(unsigned char *buf, int len) +static void asciishow(const unsigned char *buf, int len) { int i; @@ -35,7 +35,7 @@ static void asciishow(unsigned char *buf, int len) } } -static void hexdump(unsigned char *buf, int len, char *prefix) +static void hexdump(const unsigned char *buf, int len, const char *prefix) { int i, j; diff --git a/hmcfgusb.c b/hmcfgusb.c index b9b0f23..9473382 100644 --- a/hmcfgusb.c +++ b/hmcfgusb.c @@ -61,7 +61,7 @@ static int debug = 0; static int libusb_initialized = 0; /* Not in all libusb-1.0 versions, so we have to roll our own :-( */ -static char * usb_strerror(int e) +static const char* usb_strerror(int e) { static char unknerr[256]; @@ -99,7 +99,7 @@ static char * usb_strerror(int e) return unknerr; } -static char * usb_str_transfer_status(int e) +static const char* usb_str_transfer_status(int e) { static char unknerr[256]; diff --git a/hmland.c b/hmland.c index 38e4d6b..380c99a 100644 --- a/hmland.c +++ b/hmland.c @@ -100,7 +100,7 @@ static void print_timestamp(FILE *f) fprintf(f, "%s.%06ld: ", ts, tv.tv_usec); } -static void write_log(char *buf, int len, char *fmt, ...) +static void write_log(const char *buf, int len, const char *fmt, ...) { va_list ap; int i; diff --git a/hmsniff.c b/hmsniff.c index 01afe05..2ffb9e1 100644 --- a/hmsniff.c +++ b/hmsniff.c @@ -42,7 +42,7 @@ static int verbose = 0; /* See HMConfig.pm */ -char *hm_message_types(uint8_t type, uint8_t subtype) +const char *hm_message_types(uint8_t type, uint8_t subtype) { switch(type) { case 0x00: -- 2.39.2