From 2c24077466a299ead689c90f01f55f6d86c7386b Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Fri, 6 Nov 2015 18:18:34 +0100 Subject: [PATCH] Constify a lot more items. This fixes various compiler warnings when -Wdiscarded-qualifiers is used. --- include/libsigrok/libsigrok.h | 12 ++++++------ src/analog.c | 2 +- src/hardware/atten-pps3xxx/protocol.c | 2 +- src/hardware/atten-pps3xxx/protocol.h | 2 +- src/hardware/baylibre-acme/protocol.c | 3 ++- src/hardware/center-3xx/protocol.h | 6 +++--- src/hardware/fx2lafw/api.c | 2 +- src/hardware/hantek-dso/api.c | 3 ++- src/hardware/hantek-dso/dso.h | 6 +++--- src/hardware/kern-scale/protocol.h | 6 +++--- src/hardware/korad-kdxxxxp/protocol.c | 3 ++- src/hardware/korad-kdxxxxp/protocol.h | 6 +++--- src/hardware/lascar-el-usb/protocol.h | 2 +- src/hardware/manson-hcs-3xxx/protocol.h | 4 ++-- src/hardware/mic-985xx/protocol.h | 6 +++--- src/hardware/serial-dmm/protocol.h | 6 +++--- src/hardware/testo/protocol.c | 2 +- src/hardware/testo/protocol.h | 2 +- src/hardware/uni-t-dmm/protocol.h | 4 ++-- src/hardware/zeroplus-logic-cube/api.c | 2 +- src/hwdriver.c | 3 ++- src/input/binary.c | 2 +- src/input/chronovu_la8.c | 2 +- src/input/csv.c | 2 +- src/input/input.c | 2 +- src/input/vcd.c | 2 +- src/libsigrok-internal.h | 10 +++++----- src/output/analog.c | 2 +- src/scpi/scpi_vxi.c | 2 +- 29 files changed, 56 insertions(+), 52 deletions(-) diff --git a/include/libsigrok/libsigrok.h b/include/libsigrok/libsigrok.h index 1030f258..5309efbd 100644 --- a/include/libsigrok/libsigrok.h +++ b/include/libsigrok/libsigrok.h @@ -546,11 +546,11 @@ struct sr_analog_spec { /** Generic option struct used by various subsystems. */ struct sr_option { /* Short name suitable for commandline usage, [a-z0-9-]. */ - char *id; + const char *id; /* Short name suitable for GUI usage, can contain UTF-8. */ - char *name; + const char *name; /* Description of the option, in a sentence. */ - char *desc; + const char *desc; /* Default value for this option. */ GVariant *def; /* List of possible values, if this is an option with few values. */ @@ -645,11 +645,11 @@ struct sr_key_info { /** Data type like SR_T_STRING, etc if applicable. */ int datatype; /** Short, lowercase ID string, e.g. "serialcomm", "voltage". */ - char *id; + const char *id; /** Full capitalized name, e.g. "Serial communication". */ - char *name; + const char *name; /** Verbose description (unused currently). */ - char *description; + const char *description; }; #define SR_CONF_GET (1 << 31) diff --git a/src/analog.c b/src/analog.c index 8d87302a..f26f7a5c 100644 --- a/src/analog.c +++ b/src/analog.c @@ -45,7 +45,7 @@ struct unit_mq_string { uint64_t value; - char *str; + const char *str; }; /* Please use the same order as in enum sr_unit (libsigrok.h). */ diff --git a/src/hardware/atten-pps3xxx/protocol.c b/src/hardware/atten-pps3xxx/protocol.c index a969e976..34e0af42 100644 --- a/src/hardware/atten-pps3xxx/protocol.c +++ b/src/hardware/atten-pps3xxx/protocol.c @@ -21,7 +21,7 @@ #include #include "protocol.h" -static void dump_packet(char *msg, uint8_t *packet) +static void dump_packet(const char *msg, uint8_t *packet) { int i; char str[128]; diff --git a/src/hardware/atten-pps3xxx/protocol.h b/src/hardware/atten-pps3xxx/protocol.h index 633c0a20..b9a256d1 100644 --- a/src/hardware/atten-pps3xxx/protocol.h +++ b/src/hardware/atten-pps3xxx/protocol.h @@ -54,7 +54,7 @@ struct channel_spec { struct pps_model { int modelid; - char *name; + const char *name; int channel_modes; int num_channels; struct channel_spec channels[MAX_CHANNELS]; diff --git a/src/hardware/baylibre-acme/protocol.c b/src/hardware/baylibre-acme/protocol.c index becd6851..6726667e 100644 --- a/src/hardware/baylibre-acme/protocol.c +++ b/src/hardware/baylibre-acme/protocol.c @@ -651,7 +651,8 @@ static float read_sample(struct sr_channel *ch) SR_PRIV int bl_acme_open_channel(struct sr_channel *ch) { struct channel_priv *chp; - char path[64], *file; + char path[64]; + const char *file; int fd; chp = ch->priv; diff --git a/src/hardware/center-3xx/protocol.h b/src/hardware/center-3xx/protocol.h index 8ff5d2cc..acad71d4 100644 --- a/src/hardware/center-3xx/protocol.h +++ b/src/hardware/center-3xx/protocol.h @@ -37,9 +37,9 @@ enum { }; struct center_dev_info { - char *vendor; - char *device; - char *conn; + const char *vendor; + const char *device; + const char *conn; int num_channels; uint32_t max_sample_points; uint8_t packet_size; diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index 6376d0fb..c3f3ed4b 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -374,7 +374,7 @@ static int dev_open(struct sr_dev_inst *sdi) struct sr_dev_driver *di = sdi->driver; struct sr_usb_dev_inst *usb; struct dev_context *devc; - char *fpga_firmware = NULL; + const char *fpga_firmware = NULL; int ret; int64_t timediff_us, timediff_ms; diff --git a/src/hardware/hantek-dso/api.c b/src/hardware/hantek-dso/api.c index 7eef397a..1c9289e5 100644 --- a/src/hardware/hantek-dso/api.c +++ b/src/hardware/hantek-dso/api.c @@ -428,7 +428,8 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s { struct dev_context *devc; struct sr_usb_dev_inst *usb; - char str[128], *s; + char str[128]; + const char *s; const uint64_t *vdiv; int ch_idx; diff --git a/src/hardware/hantek-dso/dso.h b/src/hardware/hantek-dso/dso.h index 7938e9e5..44cced48 100644 --- a/src/hardware/hantek-dso/dso.h +++ b/src/hardware/hantek-dso/dso.h @@ -154,10 +154,10 @@ struct dso_profile { /* VID/PID after firmware upload */ uint16_t fw_vid; uint16_t fw_pid; - char *vendor; - char *model; + const char *vendor; + const char *model; const uint64_t *buffersizes; - char *firmware; + const char *firmware; }; struct dev_context { diff --git a/src/hardware/kern-scale/protocol.h b/src/hardware/kern-scale/protocol.h index 9be375f7..fce47003 100644 --- a/src/hardware/kern-scale/protocol.h +++ b/src/hardware/kern-scale/protocol.h @@ -27,11 +27,11 @@ struct scale_info { /** libsigrok driver info struct. */ struct sr_dev_driver di; /** Manufacturer/brand. */ - char *vendor; + const char *vendor; /** Model. */ - char *device; + const char *device; /** serialconn string. */ - char *conn; + const char *conn; /** Baud rate. */ uint32_t baudrate; /** Packet size in bytes. */ diff --git a/src/hardware/korad-kdxxxxp/protocol.c b/src/hardware/korad-kdxxxxp/protocol.c index 182908a8..bec63b4e 100644 --- a/src/hardware/korad-kdxxxxp/protocol.c +++ b/src/hardware/korad-kdxxxxp/protocol.c @@ -80,7 +80,8 @@ static void give_device_time_to_process(struct dev_context *devc) SR_PRIV int korad_kdxxxxp_set_value(struct sr_serial_dev_inst *serial, struct dev_context *devc) { - char msg[21], *cmd; + char msg[21]; + const char *cmd; float value; int ret; diff --git a/src/hardware/korad-kdxxxxp/protocol.h b/src/hardware/korad-kdxxxxp/protocol.h index 5b7ee1c3..a76b28ba 100644 --- a/src/hardware/korad-kdxxxxp/protocol.h +++ b/src/hardware/korad-kdxxxxp/protocol.h @@ -44,9 +44,9 @@ enum { /* Information on single model */ struct korad_kdxxxxp_model { int model_id; /**< Model info */ - char *vendor; /**< Vendor name */ - char *name; /**< Model name */ - char *id; /**< Model ID, as delivered by interface */ + const char *vendor; /**< Vendor name */ + const char *name; /**< Model name */ + const char *id; /**< Model ID, as delivered by interface */ int channels; /**< Number of channels */ double voltage[3]; /**< Min, max, step */ double current[3]; /**< Min, max, step */ diff --git a/src/hardware/lascar-el-usb/protocol.h b/src/hardware/lascar-el-usb/protocol.h index 08197fb2..482c4a97 100644 --- a/src/hardware/lascar-el-usb/protocol.h +++ b/src/hardware/lascar-el-usb/protocol.h @@ -68,7 +68,7 @@ enum { struct elusb_profile { int modelid; - char *modelname; + const char *modelname; int logformat; }; diff --git a/src/hardware/manson-hcs-3xxx/protocol.h b/src/hardware/manson-hcs-3xxx/protocol.h index c63f943d..8e614ce2 100644 --- a/src/hardware/manson-hcs-3xxx/protocol.h +++ b/src/hardware/manson-hcs-3xxx/protocol.h @@ -58,8 +58,8 @@ enum { /** Information on a single model. */ struct hcs_model { int model_id; /**< Model info */ - char *name; /**< Model name */ - char *id; /**< Model ID, like delivered by interface */ + const char *name; /**< Model name */ + const char *id; /**< Model ID, like delivered by interface */ double voltage[3]; /**< Min, max, step */ double current[3]; /**< Min, max, step */ }; diff --git a/src/hardware/mic-985xx/protocol.h b/src/hardware/mic-985xx/protocol.h index 42a01daf..f0e31a61 100644 --- a/src/hardware/mic-985xx/protocol.h +++ b/src/hardware/mic-985xx/protocol.h @@ -36,9 +36,9 @@ enum { }; struct mic_dev_info { - char *vendor; - char *device; - char *conn; + const char *vendor; + const char *device; + const char *conn; uint32_t max_sample_points; gboolean has_temperature; gboolean has_humidity; diff --git a/src/hardware/serial-dmm/protocol.h b/src/hardware/serial-dmm/protocol.h index 1a0b5939..3c2d88b8 100644 --- a/src/hardware/serial-dmm/protocol.h +++ b/src/hardware/serial-dmm/protocol.h @@ -26,11 +26,11 @@ struct dmm_info { /** libsigrok driver info struct. */ struct sr_dev_driver di; /** Manufacturer/brand. */ - char *vendor; + const char *vendor; /** Model. */ - char *device; + const char *device; /** serialconn string. */ - char *conn; + const char *conn; /** Baud rate. */ uint32_t baudrate; /** Packet size in bytes. */ diff --git a/src/hardware/testo/protocol.c b/src/hardware/testo/protocol.c index e2c43c08..be36023f 100644 --- a/src/hardware/testo/protocol.c +++ b/src/hardware/testo/protocol.c @@ -61,7 +61,7 @@ SR_PRIV int testo_probe_channels(struct sr_dev_inst *sdi) struct sr_usb_dev_inst *usb; int unit, packet_len, len, i; unsigned char packet[MAX_REPLY_SIZE], buf[MAX_REPLY_SIZE]; - char *probe_name; + const char *probe_name; devc = sdi->priv; usb = sdi->conn; diff --git a/src/hardware/testo/protocol.h b/src/hardware/testo/protocol.h index 8621bc2c..06a29644 100644 --- a/src/hardware/testo/protocol.h +++ b/src/hardware/testo/protocol.h @@ -46,7 +46,7 @@ #define EP_OUT 2 | LIBUSB_ENDPOINT_OUT struct testo_model { - char *name; + const char *name; int request_size; const uint8_t *request; }; diff --git a/src/hardware/uni-t-dmm/protocol.h b/src/hardware/uni-t-dmm/protocol.h index 9844f20e..f8fdbb5a 100644 --- a/src/hardware/uni-t-dmm/protocol.h +++ b/src/hardware/uni-t-dmm/protocol.h @@ -31,8 +31,8 @@ struct dmm_info { struct sr_dev_driver di; - char *vendor; - char *device; + const char *vendor; + const char *device; uint32_t baudrate; int packet_size; gboolean (*packet_valid)(const uint8_t *); diff --git a/src/hardware/zeroplus-logic-cube/api.c b/src/hardware/zeroplus-logic-cube/api.c index 50b7df9e..6a76b3d8 100644 --- a/src/hardware/zeroplus-logic-cube/api.c +++ b/src/hardware/zeroplus-logic-cube/api.c @@ -31,7 +31,7 @@ struct zp_model { uint16_t vid; uint16_t pid; - char *model_name; + const char *model_name; unsigned int channels; unsigned int sample_depth; /* In Ksamples/channel */ unsigned int max_sampling_freq; diff --git a/src/hwdriver.c b/src/hwdriver.c index c5d4bf29..b15fc28f 100644 --- a/src/hwdriver.c +++ b/src/hwdriver.c @@ -569,7 +569,8 @@ static int check_key(const struct sr_dev_driver *driver, GVariant *gvar_opts; const uint32_t *opts; uint32_t pub_opt; - char *suffix, *opstr; + const char *suffix; + const char *opstr; if (sdi && cg) suffix = " for this device and channel group"; diff --git a/src/input/binary.c b/src/input/binary.c index 736e4cf2..8c5a19fd 100644 --- a/src/input/binary.c +++ b/src/input/binary.c @@ -150,7 +150,7 @@ static struct sr_option options[] = { ALL_ZERO }; -static struct sr_option *get_options(void) +static const struct sr_option *get_options(void) { if (!options[0].def) { options[0].def = g_variant_ref_sink(g_variant_new_int32(DEFAULT_NUM_CHANNELS)); diff --git a/src/input/chronovu_la8.c b/src/input/chronovu_la8.c index 53e14773..1491e042 100644 --- a/src/input/chronovu_la8.c +++ b/src/input/chronovu_la8.c @@ -162,7 +162,7 @@ static struct sr_option options[] = { ALL_ZERO }; -static struct sr_option *get_options(void) +static const struct sr_option *get_options(void) { if (!options[0].def) { options[0].def = g_variant_ref_sink(g_variant_new_int32(DEFAULT_NUM_CHANNELS)); diff --git a/src/input/csv.c b/src/input/csv.c index cc451bac..7b884674 100644 --- a/src/input/csv.c +++ b/src/input/csv.c @@ -784,7 +784,7 @@ static struct sr_option options[] = { ALL_ZERO }; -static struct sr_option *get_options(void) +static const struct sr_option *get_options(void) { if (!options[0].def) { options[0].def = g_variant_ref_sink(g_variant_new_int32(0)); diff --git a/src/input/input.c b/src/input/input.c index 5e8f2129..9d471ca4 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -242,7 +242,7 @@ SR_API struct sr_input *sr_input_new(const struct sr_input_module *imod, GHashTable *options) { struct sr_input *in; - struct sr_option *mod_opts; + const struct sr_option *mod_opts; const GVariantType *gvt; GHashTable *new_opts; GHashTableIter iter; diff --git a/src/input/vcd.c b/src/input/vcd.c index 75efc0d5..6089ac84 100644 --- a/src/input/vcd.c +++ b/src/input/vcd.c @@ -551,7 +551,7 @@ static struct sr_option options[] = { ALL_ZERO }; -static struct sr_option *get_options(void) +static const struct sr_option *get_options(void) { if (!options[0].def) { options[0].def = g_variant_ref_sink(g_variant_new_int32(DEFAULT_NUM_CHANNELS)); diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index 4f44b53b..84ad295e 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -288,7 +288,7 @@ struct sr_input_module { * Returns a NULL-terminated list of options this module can take. * Can be NULL, if the module has no options. */ - struct sr_option *(*options) (void); + const struct sr_option *(*options) (void); /** * Check if this input module can load and parse the specified stream. @@ -383,7 +383,7 @@ struct sr_output_module { * A unique ID for this output module, suitable for use in command-line * clients, [a-z0-9-]. Must not be NULL. */ - char *id; + const char *id; /** * A unique name for this output module, suitable for use in GUI @@ -397,7 +397,7 @@ struct sr_output_module { * This can be displayed by frontends, e.g. when selecting the output * module for saving a file. */ - char *desc; + const char *desc; /** * A NULL terminated array of strings containing a list of file name @@ -491,7 +491,7 @@ struct sr_transform_module { * A unique ID for this transform module, suitable for use in * command-line clients, [a-z0-9-]. Must not be NULL. */ - char *id; + const char *id; /** * A unique name for this transform module, suitable for use in GUI @@ -505,7 +505,7 @@ struct sr_transform_module { * This can be displayed by frontends, e.g. when selecting * which transform module(s) to add. */ - char *desc; + const char *desc; /** * Returns a NULL-terminated list of options this transform module diff --git a/src/output/analog.c b/src/output/analog.c index 88b85d18..ed480ca0 100644 --- a/src/output/analog.c +++ b/src/output/analog.c @@ -68,7 +68,7 @@ static int init(struct sr_output *o, GHashTable *options) return SR_OK; } -static void si_printf(float value, GString *out, char *unitstr) +static void si_printf(float value, GString *out, const char *unitstr) { float v; diff --git a/src/scpi/scpi_vxi.c b/src/scpi/scpi_vxi.c index 26cd832d..8a99ec74 100644 --- a/src/scpi/scpi_vxi.c +++ b/src/scpi/scpi_vxi.c @@ -76,7 +76,7 @@ static int scpi_vxi_open(struct sr_scpi_dev_inst *scpi) link_parms.clientId = (long) vxi->client; link_parms.lockDevice = 0; link_parms.lock_timeout = VXI_DEFAULT_TIMEOUT_MS; - link_parms.device = "inst0"; + link_parms.device = (char *)"inst0"; if (!(link_resp = create_link_1(&link_parms, vxi->client))) { sr_err("Link creation failed for %s", vxi->address);