From 329733d92c5004f0fe308eff26b9537fded2cdf3 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Fri, 20 Mar 2015 14:48:20 +0100 Subject: [PATCH] Constify a few arrays and variables. --- src/hardware/atten-pps3xxx/api.c | 4 +-- src/hardware/atten-pps3xxx/protocol.h | 2 +- src/hardware/brymen-bm86x/protocol.c | 2 +- src/hardware/cem-dt-885x/protocol.c | 2 +- src/hardware/chronovu-la/api.c | 2 +- src/hardware/demo/demo.c | 2 +- src/hardware/fluke-dmm/api.c | 2 +- src/hardware/hameg-hmo/api.c | 12 ++++----- src/hardware/hameg-hmo/protocol.c | 14 +++++----- src/hardware/hameg-hmo/protocol.h | 2 +- src/hardware/ikalogic-scanaplus/api.c | 2 +- src/hardware/manson-hcs-3xxx/api.c | 2 +- src/hardware/manson-hcs-3xxx/protocol.h | 2 +- src/hardware/motech-lps-30x/api.c | 2 +- src/hardware/motech-lps-30x/protocol.h | 2 +- src/hardware/scpi-pps/api.c | 8 +++--- src/hardware/scpi-pps/profiles.c | 34 ++++++++++++------------- src/hardware/scpi-pps/protocol.c | 9 ++++--- src/hardware/scpi-pps/protocol.h | 22 ++++++++-------- src/hardware/serial-dmm/api.c | 2 +- src/hardware/testo/api.c | 5 ++-- src/hardware/testo/protocol.c | 4 +-- src/hardware/testo/protocol.h | 8 +++--- src/hardware/uni-t-dmm/api.c | 2 +- src/hardware/uni-t-dmm/protocol.c | 2 +- src/hardware/yokogawa-dlm/api.c | 14 +++++----- src/hardware/yokogawa-dlm/protocol.c | 12 ++++----- src/hardware/yokogawa-dlm/protocol.h | 2 +- src/input/csv.c | 7 ++--- src/scpi/scpi_serial.c | 2 +- 30 files changed, 95 insertions(+), 92 deletions(-) diff --git a/src/hardware/atten-pps3xxx/api.c b/src/hardware/atten-pps3xxx/api.c index ceae0274..8cce8401 100644 --- a/src/hardware/atten-pps3xxx/api.c +++ b/src/hardware/atten-pps3xxx/api.c @@ -60,7 +60,7 @@ static const char *channel_modes[] = { "Parallel", }; -static struct pps_model models[] = { +static const struct pps_model models[] = { { PPS_3203T_3S, "PPS3203T-3S", CHANMODE_INDEPENDENT | CHANMODE_SERIES | CHANMODE_PARALLEL, 3, @@ -92,7 +92,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options, int modelid) struct sr_channel_group *cg; struct sr_serial_dev_inst *serial; GSList *l, *devices; - struct pps_model *model; + const struct pps_model *model; uint8_t packet[PACKET_SIZE]; unsigned int i; int delay_ms, ret; diff --git a/src/hardware/atten-pps3xxx/protocol.h b/src/hardware/atten-pps3xxx/protocol.h index 36ee281a..01983d3b 100644 --- a/src/hardware/atten-pps3xxx/protocol.h +++ b/src/hardware/atten-pps3xxx/protocol.h @@ -74,7 +74,7 @@ struct per_channel_config { /** Private, per-device-instance driver context. */ struct dev_context { /* Model-specific information */ - struct pps_model *model; + const struct pps_model *model; /* Acquisition state */ gboolean acquisition_running; diff --git a/src/hardware/brymen-bm86x/protocol.c b/src/hardware/brymen-bm86x/protocol.c index d300149d..4de8a74c 100644 --- a/src/hardware/brymen-bm86x/protocol.c +++ b/src/hardware/brymen-bm86x/protocol.c @@ -23,7 +23,7 @@ #define USB_TIMEOUT 500 -static char char_map[128] = { +static const char char_map[128] = { [0x20] = '-', [0x5F] = '0', [0x50] = '1', diff --git a/src/hardware/cem-dt-885x/protocol.c b/src/hardware/cem-dt-885x/protocol.c index bbb1a03a..00dbd0c4 100644 --- a/src/hardware/cem-dt-885x/protocol.c +++ b/src/hardware/cem-dt-885x/protocol.c @@ -21,7 +21,7 @@ #include "protocol.h" /* Length of expected payload for each token. */ -static int token_payloads[][2] = { +static const int token_payloads[][2] = { { TOKEN_WEIGHT_TIME_FAST, 0 }, { TOKEN_WEIGHT_TIME_SLOW, 0 }, { TOKEN_HOLD_MAX, 0 }, diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c index 7d4aae04..379b0a4a 100644 --- a/src/hardware/chronovu-la/api.c +++ b/src/hardware/chronovu-la/api.c @@ -39,7 +39,7 @@ static const int32_t trigger_matches[] = { }; /* The ChronoVu LA8/LA16 can have multiple VID/PID pairs. */ -static struct { +static const struct { uint16_t vid; uint16_t pid; int model; diff --git a/src/hardware/demo/demo.c b/src/hardware/demo/demo.c index f3c8bb4a..284396a3 100644 --- a/src/hardware/demo/demo.c +++ b/src/hardware/demo/demo.c @@ -168,7 +168,7 @@ static const uint64_t samplerates[] = { SR_HZ(1), }; -static uint8_t pattern_sigrok[] = { +static const uint8_t pattern_sigrok[] = { 0x4c, 0x92, 0x92, 0x92, 0x64, 0x00, 0x00, 0x00, 0x82, 0xfe, 0xfe, 0x82, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x82, 0x82, 0x92, 0x74, 0x00, 0x00, 0x00, diff --git a/src/hardware/fluke-dmm/api.c b/src/hardware/fluke-dmm/api.c index 52bb084a..216c6359 100644 --- a/src/hardware/fluke-dmm/api.c +++ b/src/hardware/fluke-dmm/api.c @@ -41,7 +41,7 @@ static const uint32_t devopts[] = { SR_PRIV struct sr_dev_driver flukedmm_driver_info; -static char *scan_conn[] = { +static const char *scan_conn[] = { /* 287/289 */ "115200/8n1", /* 187/189 */ diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index 46db733e..4622ab61 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -180,7 +180,7 @@ static int check_channel_group(struct dev_context *devc, const struct sr_channel_group *cg) { unsigned int i; - struct scope_config *model; + const struct scope_config *model; model = devc->model_config; @@ -206,7 +206,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s int ret, cg_type; unsigned int i; struct dev_context *devc; - struct scope_config *model; + const struct scope_config *model; struct scope_state *state; if (!sdi || !(devc = sdi->priv)) @@ -331,7 +331,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd unsigned int i, j; char command[MAX_COMMAND_SIZE], float_str[30]; struct dev_context *devc; - struct scope_config *model; + const struct scope_config *model; struct scope_state *state; const char *tmp; uint64_t p, q; @@ -501,7 +501,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * { int cg_type = CG_NONE; struct dev_context *devc = NULL; - struct scope_config *model = NULL; + const struct scope_config *model = NULL; if (sdi && (devc = sdi->priv)) { if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID) @@ -572,7 +572,7 @@ SR_PRIV int hmo_request_data(const struct sr_dev_inst *sdi) char command[MAX_COMMAND_SIZE]; struct sr_channel *ch; struct dev_context *devc; - struct scope_config *model; + const struct scope_config *model; devc = sdi->priv; model = devc->model_config; @@ -640,7 +640,7 @@ static int hmo_setup_channels(const struct sr_dev_inst *sdi) gboolean *pod_enabled, setup_changed; char command[MAX_COMMAND_SIZE]; struct scope_state *state; - struct scope_config *model; + const struct scope_config *model; struct sr_channel *ch; struct dev_context *devc; struct sr_scpi_dev_inst *scpi; diff --git a/src/hardware/hameg-hmo/protocol.c b/src/hardware/hameg-hmo/protocol.c index 783c3ebc..8c5589bd 100644 --- a/src/hardware/hameg-hmo/protocol.c +++ b/src/hardware/hameg-hmo/protocol.c @@ -194,7 +194,7 @@ static const char *scope_digital_channel_names[] = { "D15", }; -static struct scope_config scope_models[] = { +static const struct scope_config scope_models[] = { { .name = {"HMO722", "HMO1022", "HMO1522", "HMO2022", NULL}, .analog_channels = 2, @@ -257,7 +257,7 @@ static struct scope_config scope_models[] = { }, }; -static void scope_state_dump(struct scope_config *config, +static void scope_state_dump(const struct scope_config *config, struct scope_state *state) { unsigned int i; @@ -326,7 +326,7 @@ static int scope_state_get_array_option(struct sr_scpi_dev_inst *scpi, } static int analog_channel_state_get(struct sr_scpi_dev_inst *scpi, - struct scope_config *config, + const struct scope_config *config, struct scope_state *state) { unsigned int i, j; @@ -381,7 +381,7 @@ static int analog_channel_state_get(struct sr_scpi_dev_inst *scpi, } static int digital_channel_state_get(struct sr_scpi_dev_inst *scpi, - struct scope_config *config, + const struct scope_config *config, struct scope_state *state) { unsigned int i; @@ -414,7 +414,7 @@ SR_PRIV int hmo_update_sample_rate(const struct sr_dev_inst *sdi) { struct dev_context *devc; struct scope_state *state; - struct scope_config *config; + const struct scope_config *config; int tmp; unsigned int i; @@ -476,7 +476,7 @@ SR_PRIV int hmo_scope_state_get(struct sr_dev_inst *sdi) { struct dev_context *devc; struct scope_state *state; - struct scope_config *config; + const struct scope_config *config; float tmp_float; unsigned int i; @@ -539,7 +539,7 @@ SR_PRIV int hmo_scope_state_get(struct sr_dev_inst *sdi) return SR_OK; } -static struct scope_state *scope_state_new(struct scope_config *config) +static struct scope_state *scope_state_new(const struct scope_config *config) { struct scope_state *state; diff --git a/src/hardware/hameg-hmo/protocol.h b/src/hardware/hameg-hmo/protocol.h index 5e19ca43..8235b1e7 100644 --- a/src/hardware/hameg-hmo/protocol.h +++ b/src/hardware/hameg-hmo/protocol.h @@ -90,7 +90,7 @@ struct scope_state { /** Private, per-device-instance driver context. */ struct dev_context { - void *model_config; + const void *model_config; void *model_state; struct sr_channel_group **analog_groups; diff --git a/src/hardware/ikalogic-scanaplus/api.c b/src/hardware/ikalogic-scanaplus/api.c index 6e311cbd..37eecbd0 100644 --- a/src/hardware/ikalogic-scanaplus/api.c +++ b/src/hardware/ikalogic-scanaplus/api.c @@ -42,7 +42,7 @@ static const char *channel_names[] = { }; /* Note: The IKALOGIC ScanaPLUS always samples at 100MHz. */ -static uint64_t samplerates[1] = { SR_MHZ(100) }; +static const uint64_t samplerates[1] = { SR_MHZ(100) }; SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info; diff --git a/src/hardware/manson-hcs-3xxx/api.c b/src/hardware/manson-hcs-3xxx/api.c index b9e6524b..d3fb8193 100644 --- a/src/hardware/manson-hcs-3xxx/api.c +++ b/src/hardware/manson-hcs-3xxx/api.c @@ -52,7 +52,7 @@ static const uint32_t devopts[] = { }; /* Note: All models have one power supply output only. */ -static struct hcs_model models[] = { +static const struct hcs_model models[] = { { MANSON_HCS_3100, "HCS-3100", "3100", { 1, 18, 0.1 }, { 0, 10, 0.10 } }, { MANSON_HCS_3102, "HCS-3102", "3102", { 1, 36, 0.1 }, { 0, 5, 0.01 } }, { MANSON_HCS_3104, "HCS-3104", "3104", { 1, 60, 0.1 }, { 0, 2.5, 0.01 } }, diff --git a/src/hardware/manson-hcs-3xxx/protocol.h b/src/hardware/manson-hcs-3xxx/protocol.h index b4441d07..e9035377 100644 --- a/src/hardware/manson-hcs-3xxx/protocol.h +++ b/src/hardware/manson-hcs-3xxx/protocol.h @@ -66,7 +66,7 @@ struct hcs_model { /** Private, per-device-instance driver context. */ struct dev_context { - struct hcs_model *model; /**< Model informaion. */ + const struct hcs_model *model; /**< Model informaion. */ uint64_t limit_samples; uint64_t limit_msec; diff --git a/src/hardware/motech-lps-30x/api.c b/src/hardware/motech-lps-30x/api.c index c23f84a1..0ed6b09b 100644 --- a/src/hardware/motech-lps-30x/api.c +++ b/src/hardware/motech-lps-30x/api.c @@ -88,7 +88,7 @@ static const char *channel_modes[] = { "Track2", }; -static struct lps_modelspec models[] = { +static const struct lps_modelspec models[] = { { LPS_UNKNOWN, "Dummy", 0, { diff --git a/src/hardware/motech-lps-30x/protocol.h b/src/hardware/motech-lps-30x/protocol.h index 76f646d8..ad7fc070 100644 --- a/src/hardware/motech-lps-30x/protocol.h +++ b/src/hardware/motech-lps-30x/protocol.h @@ -95,7 +95,7 @@ struct channel_status { /** Private, per-device-instance driver context. */ struct dev_context { /* Model-specific information */ - struct lps_modelspec* model; + const struct lps_modelspec* model; /* Acquisition status */ gboolean acq_running; /**< Aquisition is running. */ diff --git a/src/hardware/scpi-pps/api.c b/src/hardware/scpi-pps/api.c index 33d94286..9da52579 100644 --- a/src/hardware/scpi-pps/api.c +++ b/src/hardware/scpi-pps/api.c @@ -33,7 +33,7 @@ static const uint32_t drvopts[] = { SR_CONF_POWER_SUPPLY, }; -static struct pps_channel_instance pci[] = { +static const struct pps_channel_instance pci[] = { { SR_MQ_VOLTAGE, SCPI_CMD_GET_MEAS_VOLTAGE, "V" }, { SR_MQ_CURRENT, SCPI_CMD_GET_MEAS_CURRENT, "I" }, { SR_MQ_POWER, SCPI_CMD_GET_MEAS_POWER, "P" }, @@ -104,9 +104,9 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) if (device->num_channels) { /* Static channels and groups. */ - channels = device->channels; + channels = (struct channel_spec *)device->channels; num_channels = device->num_channels; - channel_groups = device->channel_groups; + channel_groups = (struct channel_group_spec *)device->channel_groups; num_channel_groups = device->num_channel_groups; } else { /* Channels and groups need to be probed. */ @@ -419,7 +419,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * { struct dev_context *devc; struct sr_channel *ch; - struct channel_spec *ch_spec; + const struct channel_spec *ch_spec; GVariant *gvar; GVariantBuilder gvb; int ret, i; diff --git a/src/hardware/scpi-pps/profiles.c b/src/hardware/scpi-pps/profiles.c index e7d3119a..50d7d93a 100644 --- a/src/hardware/scpi-pps/profiles.c +++ b/src/hardware/scpi-pps/profiles.c @@ -63,35 +63,35 @@ static const uint32_t rigol_dp800_devopts_cg[] = { SR_CONF_OUTPUT_ENABLED | SR_CONF_GET | SR_CONF_SET, }; -struct channel_spec rigol_dp821a_ch[] = { +const struct channel_spec rigol_dp821a_ch[] = { { "1", { 0, 60, 0.001 }, { 0, 1, 0.0001 } }, { "2", { 0, 8, 0.001 }, { 0, 10, 0.001 } }, }; -struct channel_spec rigol_dp831_ch[] = { +const struct channel_spec rigol_dp831_ch[] = { { "1", { 0, 8, 0.001 }, { 0, 5, 0.0003 } }, { "2", { 0, 30, 0.001 }, { 0, 2, 0.0001 } }, { "3", { 0, -30, 0.001 }, { 0, 2, 0.0001 } }, }; -struct channel_spec rigol_dp832_ch[] = { +const struct channel_spec rigol_dp832_ch[] = { { "1", { 0, 30, 0.001 }, { 0, 3, 0.001 } }, { "2", { 0, 30, 0.001 }, { 0, 3, 0.001 } }, { "3", { 0, 5, 0.001 }, { 0, 3, 0.001 } }, }; -struct channel_group_spec rigol_dp820_cg[] = { +const struct channel_group_spec rigol_dp820_cg[] = { { "1", CH_IDX(0), PPS_OVP | PPS_OCP }, { "2", CH_IDX(1), PPS_OVP | PPS_OCP }, }; -struct channel_group_spec rigol_dp830_cg[] = { +const struct channel_group_spec rigol_dp830_cg[] = { { "1", CH_IDX(0), PPS_OVP | PPS_OCP }, { "2", CH_IDX(1), PPS_OVP | PPS_OCP }, { "3", CH_IDX(2), PPS_OVP | PPS_OCP }, }; -struct scpi_command rigol_dp800_cmd[] = { +const struct scpi_command rigol_dp800_cmd[] = { { SCPI_CMD_REMOTE, "SYST:REMOTE" }, { SCPI_CMD_LOCAL, "SYST:LOCAL" }, { SCPI_CMD_BEEPER, "SYST:BEEP:STAT?" }, @@ -136,15 +136,15 @@ static const uint32_t hp_6632b_devopts[] = { SR_CONF_OUTPUT_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, }; -struct channel_spec hp_6632b_ch[] = { +const struct channel_spec hp_6632b_ch[] = { { "1", { 0, 20.475, 0.005 }, { 0, 5.1188, 0.00132 } }, }; -struct channel_group_spec hp_6632b_cg[] = { +const struct channel_group_spec hp_6632b_cg[] = { { "1", CH_IDX(0), 0 }, }; -struct scpi_command hp_6632b_cmd[] = { +const struct scpi_command hp_6632b_cmd[] = { { SCPI_CMD_GET_OUTPUT_ENABLED, "OUTP:STAT?" }, { SCPI_CMD_SET_OUTPUT_ENABLE, "OUTP:STAT ON" }, { SCPI_CMD_SET_OUTPUT_DISABLE, "OUTP:STAT OFF" }, @@ -183,7 +183,7 @@ enum philips_pm2800_modules { PM2800_MOD_120V_1A, }; -static struct philips_pm2800_module_spec { +static const struct philips_pm2800_module_spec { /* Min, max, programming resolution. */ float voltage[3]; float current[3]; @@ -198,7 +198,7 @@ static struct philips_pm2800_module_spec { [PM2800_MOD_120V_1A] = { { 0, 120, 0.030 }, { -1, 1, 0.00025 } }, }; -static struct philips_pm2800_model { +static const struct philips_pm2800_model { unsigned int chassis; unsigned int num_modules; unsigned int set; @@ -226,15 +226,15 @@ static struct philips_pm2800_model { { 3, 2, 3, { PM2800_MOD_8V_15A, PM2800_MOD_8V_15A, 0 } }, }; -static char *philips_pm2800_names[] = { "1", "2", "3" }; +static const char *philips_pm2800_names[] = { "1", "2", "3" }; static int philips_pm2800_probe_channels(struct sr_dev_inst *sdi, struct sr_scpi_hw_info *hw_info, struct channel_spec **channels, unsigned int *num_channels, struct channel_group_spec **channel_groups, unsigned int *num_channel_groups) { - struct philips_pm2800_model *model; - struct philips_pm2800_module_spec *spec; + const struct philips_pm2800_model *model; + const struct philips_pm2800_module_spec *spec; unsigned int chassis, num_modules, set, module, m, i; (void)sdi; @@ -270,9 +270,9 @@ static int philips_pm2800_probe_channels(struct sr_dev_inst *sdi, sr_dbg("output %d: %.0f - %.0fV, %.0f - %.0fA", i + 1, spec->voltage[0], spec->voltage[1], spec->current[0], spec->current[1]); - (*channels)[i].name = philips_pm2800_names[i]; + (*channels)[i].name = (char *)philips_pm2800_names[i]; memcpy(&((*channels)[i].voltage), spec, sizeof(float) * 6); - (*channel_groups)[i].name = philips_pm2800_names[i]; + (*channel_groups)[i].name = (char *)philips_pm2800_names[i]; (*channel_groups)[i].channel_index_mask = 1 << i; (*channel_groups)[i].features = PPS_OTP | PPS_OVP | PPS_OCP; } @@ -281,7 +281,7 @@ static int philips_pm2800_probe_channels(struct sr_dev_inst *sdi, return SR_OK; } -struct scpi_command philips_pm2800_cmd[] = { +const struct scpi_command philips_pm2800_cmd[] = { { SCPI_CMD_SELECT_CHANNEL, ":INST:NSEL %s" }, { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" }, { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" }, diff --git a/src/hardware/scpi-pps/protocol.c b/src/hardware/scpi-pps/protocol.c index 86ec3876..be478860 100644 --- a/src/hardware/scpi-pps/protocol.c +++ b/src/hardware/scpi-pps/protocol.c @@ -21,11 +21,11 @@ #include #include "protocol.h" -SR_PRIV char *scpi_cmd_get(const struct sr_dev_inst *sdi, int command) +SR_PRIV const char *scpi_cmd_get(const struct sr_dev_inst *sdi, int command) { struct dev_context *devc; unsigned int i; - char *cmd; + const char *cmd; devc = sdi->priv; cmd = NULL; @@ -44,7 +44,7 @@ SR_PRIV int scpi_cmd(const struct sr_dev_inst *sdi, int command, ...) struct sr_scpi_dev_inst *scpi; va_list args; int ret; - char *cmd; + const char *cmd; if (!(cmd = scpi_cmd_get(sdi, command))) { /* Device does not implement this command, that's OK. */ @@ -66,7 +66,8 @@ SR_PRIV int scpi_cmd_resp(const struct sr_dev_inst *sdi, GVariant **gvar, va_list args; double d; int ret; - char *cmd, *s; + char *s; + const char *cmd; if (!(cmd = scpi_cmd_get(sdi, command))) { /* Device does not implement this command, that's OK. */ diff --git a/src/hardware/scpi-pps/protocol.h b/src/hardware/scpi-pps/protocol.h index 7a06093f..bd0dc933 100644 --- a/src/hardware/scpi-pps/protocol.h +++ b/src/hardware/scpi-pps/protocol.h @@ -77,18 +77,18 @@ enum pps_features { }; struct scpi_pps { - char *vendor; - char *model; + const char *vendor; + const char *model; uint64_t features; const uint32_t *devopts; unsigned int num_devopts; const uint32_t *devopts_cg; unsigned int num_devopts_cg; - struct channel_spec *channels; + const struct channel_spec *channels; unsigned int num_channels; - struct channel_group_spec *channel_groups; + const struct channel_group_spec *channel_groups; unsigned int num_channel_groups; - struct scpi_command *commands; + const struct scpi_command *commands; unsigned int num_commands; int (*probe_channels) (struct sr_dev_inst *sdi, struct sr_scpi_hw_info *hwinfo, struct channel_spec **channels, unsigned int *num_channels, @@ -96,7 +96,7 @@ struct scpi_pps { }; struct channel_spec { - char *name; + const char *name; /* Min, max, programming resolution. */ float voltage[3]; float current[3]; @@ -104,11 +104,11 @@ struct channel_spec { struct scpi_command { int command; - char *string; + const char *string; }; struct channel_group_spec { - char *name; + const char *name; uint64_t channel_index_mask; uint64_t features; }; @@ -116,13 +116,13 @@ struct channel_group_spec { struct pps_channel { int mq; unsigned int hw_output_idx; - char *hwname; + const char *hwname; }; struct pps_channel_instance { int mq; int command; - char *prefix; + const char *prefix; }; struct pps_channel_group { @@ -153,7 +153,7 @@ struct dev_context { }; const char *get_vendor(const char *raw_vendor); -SR_PRIV char *scpi_cmd_get(const struct sr_dev_inst *sdi, int command); +SR_PRIV const char *scpi_cmd_get(const struct sr_dev_inst *sdi, int command); SR_PRIV int scpi_cmd(const struct sr_dev_inst *sdi, int command, ...); SR_PRIV int scpi_cmd_resp(const struct sr_dev_inst *sdi, GVariant **gvar, const GVariantType *gvtype, int command, ...); diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index 08099753..ecaba493 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -280,7 +280,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) REQUEST, VALID, PARSE, DETAILS, sizeof(struct CHIPSET##_info) \ } -SR_PRIV struct dmm_info *serial_dmm_drivers[] = { +SR_PRIV const struct dmm_info *serial_dmm_drivers[] = { DMM( "bbcgm-2010", metex14, "BBC Goertz Metrawatt", "M2110", "1200/7n2", 1200, diff --git a/src/hardware/testo/api.c b/src/hardware/testo/api.c index da6d171a..103f44ce 100644 --- a/src/hardware/testo/api.c +++ b/src/hardware/testo/api.c @@ -36,8 +36,9 @@ static const uint32_t devopts[] = { SR_CONF_LIMIT_MSEC | SR_CONF_SET, }; -unsigned char TESTO_x35_REQUEST[] = { 0x12, 0, 0, 0, 1, 1, 0x55, 0xd1, 0xb7 }; -struct testo_model models[] = { +static const uint8_t TESTO_x35_REQUEST[] = { 0x12, 0, 0, 0, 1, 1, 0x55, 0xd1, 0xb7 }; + +static const struct testo_model models[] = { { "435", 9, TESTO_x35_REQUEST }, }; diff --git a/src/hardware/testo/protocol.c b/src/hardware/testo/protocol.c index 15717c02..46e9ae62 100644 --- a/src/hardware/testo/protocol.c +++ b/src/hardware/testo/protocol.c @@ -76,7 +76,7 @@ SR_PRIV int testo_probe_channels(struct sr_dev_inst *sdi) libusb_bulk_transfer(usb->devhdl, EP_IN, buf, MAX_REPLY_SIZE, &len, 10); } while (len > 2); - if (libusb_bulk_transfer(usb->devhdl, EP_OUT, devc->model->request, + if (libusb_bulk_transfer(usb->devhdl, EP_OUT, (unsigned char *)devc->model->request, devc->model->request_size, &devc->reply_size, 10) < 0) return SR_ERR; @@ -153,7 +153,7 @@ SR_PRIV int testo_request_packet(const struct sr_dev_inst *sdi) usb = sdi->conn; libusb_fill_bulk_transfer(devc->out_transfer, usb->devhdl, EP_OUT, - devc->model->request, devc->model->request_size, + (unsigned char *)devc->model->request, devc->model->request_size, receive_transfer, (void *)sdi, 100); if ((ret = libusb_submit_transfer(devc->out_transfer) != 0)) { sr_err("Failed to request packet: %s.", libusb_error_name(ret)); diff --git a/src/hardware/testo/protocol.h b/src/hardware/testo/protocol.h index a61a9dce..c2c3a870 100644 --- a/src/hardware/testo/protocol.h +++ b/src/hardware/testo/protocol.h @@ -48,13 +48,13 @@ struct testo_model { char *name; int request_size; - unsigned char *request; + const uint8_t *request; }; /** Private, per-device-instance driver context. */ struct dev_context { /* Model-specific information */ - struct testo_model *model; + const struct testo_model *model; /* Acquisition settings */ uint64_t limit_msec; @@ -69,7 +69,7 @@ struct dev_context { /* Temporary state across callbacks */ struct libusb_transfer *out_transfer; - unsigned char reply[MAX_REPLY_SIZE]; + uint8_t reply[MAX_REPLY_SIZE]; int reply_size; }; @@ -77,7 +77,7 @@ SR_PRIV int testo_set_serial_params(struct sr_usb_dev_inst *usb); SR_PRIV int testo_probe_channels(struct sr_dev_inst *sdi); SR_PRIV void receive_transfer(struct libusb_transfer *transfer); SR_PRIV int testo_request_packet(const struct sr_dev_inst *sdi); -SR_PRIV gboolean testo_check_packet_prefix(unsigned char *buf, int len); +SR_PRIV gboolean testo_check_packet_prefix(uint8_t *buf, int len); SR_PRIV uint16_t crc16_mcrf4xx(uint16_t crc, uint8_t *data, size_t len); SR_PRIV void testo_receive_packet(const struct sr_dev_inst *sdi); diff --git a/src/hardware/uni-t-dmm/api.c b/src/hardware/uni-t-dmm/api.c index e964279d..0f872735 100644 --- a/src/hardware/uni-t-dmm/api.c +++ b/src/hardware/uni-t-dmm/api.c @@ -61,7 +61,7 @@ SR_PRIV struct sr_dev_driver voltcraft_vc960_driver_info; SR_PRIV struct sr_dev_driver tenma_72_7745_driver_info; SR_PRIV struct sr_dev_driver tenma_72_7750_driver_info; -SR_PRIV struct dmm_info udmms[] = { +SR_PRIV const struct dmm_info udmms[] = { { "Tecpel", "DMM-8061", 2400, FS9721_PACKET_SIZE, diff --git a/src/hardware/uni-t-dmm/protocol.c b/src/hardware/uni-t-dmm/protocol.c index 28bfc096..c60acb70 100644 --- a/src/hardware/uni-t-dmm/protocol.c +++ b/src/hardware/uni-t-dmm/protocol.c @@ -24,7 +24,7 @@ #include "libsigrok-internal.h" #include "protocol.h" -extern struct dmm_info udmms[]; +extern const struct dmm_info udmms[]; /* * Driver for various UNI-T multimeters (and rebranded ones). diff --git a/src/hardware/yokogawa-dlm/api.c b/src/hardware/yokogawa-dlm/api.c index 054d431d..fcc84e1b 100644 --- a/src/hardware/yokogawa-dlm/api.c +++ b/src/hardware/yokogawa-dlm/api.c @@ -23,8 +23,8 @@ SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info; -static char *MANUFACTURER_ID = "YOKOGAWA"; -static char *MANUFACTURER_NAME = "Yokogawa"; +static const char *MANUFACTURER_ID = "YOKOGAWA"; +static const char *MANUFACTURER_NAME = "Yokogawa"; static const uint32_t drvopts[] = { SR_CONF_LOGIC_ANALYZER, @@ -178,7 +178,7 @@ static int check_channel_group(struct dev_context *devc, const struct sr_channel_group *cg) { unsigned int i; - struct scope_config *model; + const struct scope_config *model; model = devc->model_config; @@ -203,7 +203,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s int ret, cg_type; unsigned int i; struct dev_context *devc; - struct scope_config *model; + const struct scope_config *model; struct scope_state *state; if (!sdi || !(devc = sdi->priv)) @@ -322,7 +322,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd unsigned int i, j; char float_str[30]; struct dev_context *devc; - struct scope_config *model; + const struct scope_config *model; struct scope_state *state; const char *tmp; uint64_t p, q; @@ -474,7 +474,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * { int cg_type = CG_NONE; struct dev_context *devc = NULL; - struct scope_config *model = NULL; + const struct scope_config *model = NULL; if (sdi && (devc = sdi->priv)) { if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID) @@ -572,7 +572,7 @@ static int dlm_setup_channels(const struct sr_dev_inst *sdi) unsigned int i; gboolean *pod_enabled, setup_changed; struct scope_state *state; - struct scope_config *model; + const struct scope_config *model; struct sr_channel *ch; struct dev_context *devc; struct sr_scpi_dev_inst *scpi; diff --git a/src/hardware/yokogawa-dlm/protocol.c b/src/hardware/yokogawa-dlm/protocol.c index 8acaf023..975bfcb8 100644 --- a/src/hardware/yokogawa-dlm/protocol.c +++ b/src/hardware/yokogawa-dlm/protocol.c @@ -168,7 +168,7 @@ static const char *scope_digital_channel_names[] = { "D7" }; -static struct scope_config scope_models[] = { +static const struct scope_config scope_models[] = { { .model_id = {"710105", "710115", "710125", NULL}, .model_name = {"DLM2022", "DLM2032", "DLM2052", NULL}, @@ -235,7 +235,7 @@ static struct scope_config scope_models[] = { * @param config This is the scope configuration. * @param state The current scope state to print. */ -static void scope_state_dump(struct scope_config *config, +static void scope_state_dump(const struct scope_config *config, struct scope_state *state) { unsigned int i; @@ -376,7 +376,7 @@ static int array_float_get(gchar *value, const uint64_t array[][2], * @return SR_ERR on error, SR_OK otherwise. */ static int analog_channel_state_get(struct sr_scpi_dev_inst *scpi, - struct scope_config *config, + const struct scope_config *config, struct scope_state *state) { int i, j; @@ -439,7 +439,7 @@ static int analog_channel_state_get(struct sr_scpi_dev_inst *scpi, * @return SR_ERR on error, SR_OK otherwise. */ static int digital_channel_state_get(struct sr_scpi_dev_inst *scpi, - struct scope_config *config, + const struct scope_config *config, struct scope_state *state) { unsigned int i; @@ -514,7 +514,7 @@ SR_PRIV int dlm_scope_state_query(struct sr_dev_inst *sdi) { struct dev_context *devc; struct scope_state *state; - struct scope_config *config; + const struct scope_config *config; float tmp_float; gchar *response; int i; @@ -588,7 +588,7 @@ SR_PRIV int dlm_scope_state_query(struct sr_dev_inst *sdi) * * @return The newly allocated scope_state struct. */ -static struct scope_state *dlm_scope_state_new(struct scope_config *config) +static struct scope_state *dlm_scope_state_new(const struct scope_config *config) { struct scope_state *state; diff --git a/src/hardware/yokogawa-dlm/protocol.h b/src/hardware/yokogawa-dlm/protocol.h index aa62f321..0bdb7f2f 100644 --- a/src/hardware/yokogawa-dlm/protocol.h +++ b/src/hardware/yokogawa-dlm/protocol.h @@ -105,7 +105,7 @@ struct scope_state { /** Private, per-device-instance driver context. */ struct dev_context { - void *model_config; + const void *model_config; void *model_state; struct sr_channel_group **analog_groups; diff --git a/src/input/csv.c b/src/input/csv.c index 47fee73e..0e68e391 100644 --- a/src/input/csv.c +++ b/src/input/csv.c @@ -454,9 +454,9 @@ static int init(struct sr_input *in, GHashTable *options) return SR_OK; } -static char *get_line_termination(GString *buf) +static const char *get_line_termination(GString *buf) { - char *term; + const char *term; term = NULL; if (g_strstr_len(buf->str, buf->len, "\r\n")) @@ -581,7 +581,8 @@ static int initial_receive(const struct sr_input *in) struct context *inc; GString *new_buf; int len, ret; - char *termination, *p; + char *p; + const char *termination; inc = in->priv; diff --git a/src/scpi/scpi_serial.c b/src/scpi/scpi_serial.c index 650f9711..7f039bf0 100644 --- a/src/scpi/scpi_serial.c +++ b/src/scpi/scpi_serial.c @@ -36,7 +36,7 @@ struct scpi_serial { size_t read; }; -static struct { +static const struct { uint16_t vendor_id; uint16_t product_id; const char *serialcomm;