From: Uwe Hermann Date: Tue, 22 Dec 2015 19:15:57 +0000 (+0100) Subject: Prefer postfix-increment for consistency across the code-base. X-Git-Tag: libsigrok-0.4.0~59 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=0a1f7b09b3fa4cc4da29c7acf53717e14b004b63;p=libsigrok.git Prefer postfix-increment for consistency across the code-base. Only when there are technical reasons use prefix-increment. --- diff --git a/src/hardware/asix-sigma/api.c b/src/hardware/asix-sigma/api.c index 8b798d4e..4ac74bda 100644 --- a/src/hardware/asix-sigma/api.c +++ b/src/hardware/asix-sigma/api.c @@ -334,7 +334,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) sigma_set_register(WRITE_TRIGGER_SELECT1, 0x81, devc); /* Find which pin to trigger on from mask. */ - for (triggerpin = 0; triggerpin < 8; ++triggerpin) + for (triggerpin = 0; triggerpin < 8; triggerpin++) if ((devc->trigger.risingmask | devc->trigger.fallingmask) & (1 << triggerpin)) break; diff --git a/src/hardware/asix-sigma/protocol.c b/src/hardware/asix-sigma/protocol.c index 01dc1c18..03d9e3c0 100644 --- a/src/hardware/asix-sigma/protocol.c +++ b/src/hardware/asix-sigma/protocol.c @@ -114,7 +114,7 @@ SR_PRIV int sigma_write_register(uint8_t reg, uint8_t *data, size_t len, buf[idx++] = REG_ADDR_LOW | (reg & 0xf); buf[idx++] = REG_ADDR_HIGH | (reg >> 4); - for (i = 0; i < len; ++i) { + for (i = 0; i < len; i++) { buf[idx++] = REG_DATA_LOW | (data[i] & 0xf); buf[idx++] = REG_DATA_HIGH_WRITE | (data[i] >> 4); } @@ -201,7 +201,7 @@ static int sigma_read_dram(uint16_t startchunk, size_t numchunks, buf[idx++] = REG_DRAM_BLOCK; buf[idx++] = REG_DRAM_WAIT_ACK; - for (i = 0; i < numchunks; ++i) { + for (i = 0; i < numchunks; i++) { /* Alternate bit to copy from DRAM to cache. */ if (i != (numchunks - 1)) buf[idx++] = REG_DRAM_BLOCK | (((i + 1) % 2) << 4); @@ -225,7 +225,7 @@ SR_PRIV int sigma_write_trigger_lut(struct triggerlut *lut, struct dev_context * uint16_t bit; /* Transpose the table and send to Sigma. */ - for (i = 0; i < 16; ++i) { + for (i = 0; i < 16; i++) { bit = 1 << i; tmp[0] = tmp[1] = 0; @@ -599,7 +599,7 @@ SR_PRIV int sigma_convert_trigger(const struct sr_dev_inst *sdi) return SR_ERR; } - ++trigger_set; + trigger_set++; } else { /* Simple trigger support (event). */ if (match->match == SR_TRIGGER_ONE) { @@ -612,11 +612,11 @@ SR_PRIV int sigma_convert_trigger(const struct sr_dev_inst *sdi) } else if (match->match == SR_TRIGGER_FALLING) { devc->trigger.fallingmask |= channelbit; - ++trigger_set; + trigger_set++; } else if (match->match == SR_TRIGGER_RISING) { devc->trigger.risingmask |= channelbit; - ++trigger_set; + trigger_set++; } /* @@ -644,7 +644,7 @@ static int get_trigger_offset(uint8_t *samples, uint16_t last_sample, int i; uint16_t sample = 0; - for (i = 0; i < 8; ++i) { + for (i = 0; i < 8; i++) { if (i > 0) last_sample = sample; sample = samples[2 * i] | (samples[2 * i + 1] << 8); @@ -976,20 +976,19 @@ static void build_lut_entry(uint16_t value, uint16_t mask, uint16_t *entry) int i, j, k, bit; /* For each quad channel. */ - for (i = 0; i < 4; ++i) { + for (i = 0; i < 4; i++) { entry[i] = 0xffff; /* For each bit in LUT. */ - for (j = 0; j < 16; ++j) + for (j = 0; j < 16; j++) /* For each channel in quad. */ - for (k = 0; k < 4; ++k) { + for (k = 0; k < 4; k++) { bit = 1 << (i * 4 + k); /* Set bit in entry */ - if ((mask & bit) && - ((!(value & bit)) != - (!(j & (1 << k))))) + if ((mask & bit) && ((!(value & bit)) != + (!(j & (1 << k))))) entry[i] &= ~(1 << j); } } @@ -1042,17 +1041,17 @@ static void add_trigger_function(enum triggerop oper, enum triggerfunc func, /* Transpose if neg is set. */ if (neg) { - for (i = 0; i < 2; ++i) { - for (j = 0; j < 2; ++j) { + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { tmp = x[i][j]; - x[i][j] = x[1-i][1-j]; - x[1-i][1-j] = tmp; + x[i][j] = x[1 - i][1 - j]; + x[1 - i][1 - j] = tmp; } } } /* Update mask with function. */ - for (i = 0; i < 16; ++i) { + for (i = 0; i < 16; i++) { a = (i >> (2 * index + 0)) & 1; b = (i >> (2 * index + 1)) & 1; @@ -1097,7 +1096,7 @@ SR_PRIV int sigma_build_basic_trigger(struct triggerlut *lut, struct dev_context lut->m2d); /* Rise/fall trigger support. */ - for (i = 0, j = 0; i < 16; ++i) { + for (i = 0, j = 0; i < 16; i++) { if (devc->trigger.risingmask & (1 << i) || devc->trigger.fallingmask & (1 << i)) masks[j++] = 1 << i; diff --git a/src/hardware/cem-dt-885x/protocol.c b/src/hardware/cem-dt-885x/protocol.c index a893bd1b..68d003a0 100644 --- a/src/hardware/cem-dt-885x/protocol.c +++ b/src/hardware/cem-dt-885x/protocol.c @@ -184,7 +184,7 @@ static void send_data(const struct sr_dev_inst *sdi, unsigned char *data, devc = sdi->priv; - for (i = 0; i < num_samples; i ++) { + for (i = 0; i < num_samples; i++) { fbuf[i] = ((data[i * 2] & 0xf0) >> 4) * 100; fbuf[i] += (data[i * 2] & 0x0f) * 10; fbuf[i] += ((data[i * 2 + 1] & 0xf0) >> 4); diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index 415f945b..1b36f04e 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -55,7 +55,7 @@ static int check_manufacturer(const char *manufacturer) { unsigned int i; - for (i = 0; i < ARRAY_SIZE(manufacturers); ++i) + for (i = 0; i < ARRAY_SIZE(manufacturers); i++) if (!strcmp(manufacturer, manufacturers[i])) return SR_OK; @@ -183,11 +183,11 @@ static int check_channel_group(struct dev_context *devc, if (!cg) return CG_NONE; - for (i = 0; i < model->analog_channels; ++i) + for (i = 0; i < model->analog_channels; i++) if (cg == devc->analog_groups[i]) return CG_ANALOG; - for (i = 0; i < model->digital_pods; ++i) + for (i = 0; i < model->digital_pods; i++) if (cg == devc->digital_groups[i]) return CG_DIGITAL; @@ -230,7 +230,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s sr_err("No channel group specified."); return SR_ERR_CHANNEL_GROUP; } else if (cg_type == CG_ANALOG) { - for (i = 0; i < model->analog_channels; ++i) { + for (i = 0; i < model->analog_channels; i++) { if (cg != devc->analog_groups[i]) continue; *data = g_variant_new_int32(model->num_ydivs); @@ -247,7 +247,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s sr_err("No channel group specified."); return SR_ERR_CHANNEL_GROUP; } else if (cg_type == CG_ANALOG) { - for (i = 0; i < model->analog_channels; ++i) { + for (i = 0; i < model->analog_channels; i++) { if (cg != devc->analog_groups[i]) continue; *data = g_variant_new("(tt)", @@ -278,7 +278,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s sr_err("No channel group specified."); return SR_ERR_CHANNEL_GROUP; } else if (cg_type == CG_ANALOG) { - for (i = 0; i < model->analog_channels; ++i) { + for (i = 0; i < model->analog_channels; i++) { if (cg != devc->analog_groups[i]) continue; *data = g_variant_new_string((*model->coupling_options)[state->analog_channels[i].coupling]); @@ -377,7 +377,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (p != (*model->vdivs)[i][0] || q != (*model->vdivs)[i][1]) continue; - for (j = 1; j <= model->analog_channels; ++j) { + for (j = 1; j <= model->analog_channels; j++) { if (cg != devc->analog_groups[j - 1]) continue; state->analog_channels[j - 1].vdiv = i; @@ -459,7 +459,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd for (i = 0; (*model->coupling_options)[i]; i++) { if (strcmp(tmp, (*model->coupling_options)[i]) != 0) continue; - for (j = 1; j <= model->analog_channels; ++j) { + for (j = 1; j <= model->analog_channels; j++) { if (cg != devc->analog_groups[j - 1]) continue; state->analog_channels[j-1].coupling = i; @@ -689,7 +689,7 @@ static int hmo_setup_channels(const struct sr_dev_inst *sdi) } } - for (i = 1; i <= model->digital_pods; ++i) { + for (i = 1; i <= model->digital_pods; i++) { if (state->digital_pods[i - 1] == pod_enabled[i - 1]) continue; g_snprintf(command, sizeof(command), diff --git a/src/hardware/hameg-hmo/protocol.c b/src/hardware/hameg-hmo/protocol.c index b79182d3..89825b73 100644 --- a/src/hardware/hameg-hmo/protocol.c +++ b/src/hardware/hameg-hmo/protocol.c @@ -265,7 +265,7 @@ static void scope_state_dump(const struct scope_config *config, unsigned int i; char *tmp; - for (i = 0; i < config->analog_channels; ++i) { + for (i = 0; i < config->analog_channels; i++) { tmp = sr_voltage_string((*config->vdivs)[state->analog_channels[i].vdiv][0], (*config->vdivs)[state->analog_channels[i].vdiv][1]); sr_info("State of analog channel %d -> %s : %s (coupling) %s (vdiv) %2.2e (offset)", @@ -274,12 +274,12 @@ static void scope_state_dump(const struct scope_config *config, tmp, state->analog_channels[i].vertical_offset); } - for (i = 0; i < config->digital_channels; ++i) { + for (i = 0; i < config->digital_channels; i++) { sr_info("State of digital channel %d -> %s", i, state->digital_channels[i] ? "On" : "Off"); } - for (i = 0; i < config->digital_pods; ++i) { + for (i = 0; i < config->digital_pods; i++) { sr_info("State of digital POD %d -> %s", i, state->digital_pods[i] ? "On" : "Off"); } @@ -310,7 +310,7 @@ static int scope_state_get_array_option(struct sr_scpi_dev_inst *scpi, return SR_ERR; } - for (i = 0; (*array)[i]; ++i) { + for (i = 0; (*array)[i]; i++) { if (!g_strcmp0(tmp, (*array)[i])) { *result = i; g_free(tmp); @@ -335,7 +335,7 @@ static int analog_channel_state_get(struct sr_scpi_dev_inst *scpi, float tmp_float; char command[MAX_COMMAND_SIZE]; - for (i = 0; i < config->analog_channels; ++i) { + for (i = 0; i < config->analog_channels; i++) { g_snprintf(command, sizeof(command), (*config->scpi_dialect)[SCPI_CMD_GET_ANALOG_CHAN_STATE], i + 1); @@ -389,7 +389,7 @@ static int digital_channel_state_get(struct sr_scpi_dev_inst *scpi, unsigned int i; char command[MAX_COMMAND_SIZE]; - for (i = 0; i < config->digital_channels; ++i) { + for (i = 0; i < config->digital_channels; i++) { g_snprintf(command, sizeof(command), (*config->scpi_dialect)[SCPI_CMD_GET_DIG_CHAN_STATE], i); @@ -399,7 +399,7 @@ static int digital_channel_state_get(struct sr_scpi_dev_inst *scpi, return SR_ERR; } - for (i = 0; i < config->digital_pods; ++i) { + for (i = 0; i < config->digital_pods; i++) { g_snprintf(command, sizeof(command), (*config->scpi_dialect)[SCPI_CMD_GET_DIG_POD_STATE], i + 1); @@ -430,7 +430,7 @@ SR_PRIV int hmo_update_sample_rate(const struct sr_dev_inst *sdi) state = devc->model_state; channel_found = FALSE; - for (i = 0; i < config->analog_channels; ++i) { + for (i = 0; i < config->analog_channels; i++) { if (state->analog_channels[i].state) { g_snprintf(chan_name, sizeof(chan_name), "CHAN%d", i + 1); g_snprintf(tmp_str, sizeof(tmp_str), @@ -614,7 +614,7 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi) } /* Add digital channel groups. */ - for (i = 0; i < scope_models[model_index].digital_pods; ++i) { + for (i = 0; i < scope_models[model_index].digital_pods; i++) { g_snprintf(tmp, 25, "POD%d", i); devc->digital_groups[i] = g_malloc0(sizeof(struct sr_channel_group)); diff --git a/src/hardware/sysclk-lwla/api.c b/src/hardware/sysclk-lwla/api.c index 20e30d1e..d9a66617 100644 --- a/src/hardware/sysclk-lwla/api.c +++ b/src/hardware/sysclk-lwla/api.c @@ -488,7 +488,7 @@ static int lookup_index(GVariant *value, const char *const *table, int len) return -1; /* Linear search is fine for very small tables. */ - for (i = 0; i < len; ++i) { + for (i = 0; i < len; i++) { if (strcmp(entry, table[i]) == 0) return i; } diff --git a/src/hardware/sysclk-lwla/lwla.c b/src/hardware/sysclk-lwla/lwla.c index 6a0b5606..b7a7bbe1 100644 --- a/src/hardware/sysclk-lwla/lwla.c +++ b/src/hardware/sysclk-lwla/lwla.c @@ -210,7 +210,7 @@ SR_PRIV int lwla_write_regs(const struct sr_usb_dev_inst *usb, ret = SR_OK; - for (i = 0; i < count; ++i) { + for (i = 0; i < count; i++) { ret = lwla_write_reg(usb, regvals[i].reg, regvals[i].val); if (ret != SR_OK) diff --git a/src/scpi/scpi.c b/src/scpi/scpi.c index c3c2f713..fc7e9939 100644 --- a/src/scpi/scpi.c +++ b/src/scpi/scpi.c @@ -579,7 +579,7 @@ SR_PRIV int sr_scpi_get_opc(struct sr_scpi_dev_inst *scpi) unsigned int i; gboolean opc; - for (i = 0; i < SCPI_READ_RETRIES; ++i) { + for (i = 0; i < SCPI_READ_RETRIES; i++) { sr_scpi_get_bool(scpi, SCPI_CMD_OPC, &opc); if (opc) return SR_OK;