laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1d/+/26820 )
Change subject: cosmetic: Adhere osmocom coding style in for-loops ......................................................................
cosmetic: Adhere osmocom coding style in for-loops
We either have to bring osmo-e1d in line with other osmocom projects, or we'd have to disable the linter in jenkins.
Change-Id: I74ab20b22118d471dcdb60d1b9681ab62eb13d51 --- M src/ctl.c M src/intf_line.c M src/mux_demux.c M src/usb.c 4 files changed, 17 insertions(+), 20 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/20/26820/1
diff --git a/src/ctl.c b/src/ctl.c index 4a922b9..7040001 100644 --- a/src/ctl.c +++ b/src/ctl.c @@ -278,7 +278,7 @@ if (n == 1) { _e1d_fill_ts_info(ti, &line->ts[hdr->ts]); } else { - for (int i=0; i<32; i++) + for (int i = 0; i < 32; i++) _e1d_fill_ts_info(ti++, &line->ts[i]); }
diff --git a/src/intf_line.c b/src/intf_line.c index 5659129..1f833fb 100644 --- a/src/intf_line.c +++ b/src/intf_line.c @@ -192,7 +192,7 @@ line->drv_data = drv_data; line->mode = E1_LINE_MODE_CHANNELIZED;
- for (int i=0; i<32; i++) + for (int i = 0; i < 32; i++) _ts_init(&line->ts[i], line, i); _ts_init(&line->superchan, line, E1DP_TS_SUPERCHAN);
@@ -228,7 +228,7 @@ osmo_timer_del(&line->watchdog.timer);
/* close all [peer] file descriptors */ - for (int i=0; i<32; i++) + for (int i = 0; i < 32; i++) e1_ts_stop(&line->ts[i]);
/* remove from per-interface list of lines */ diff --git a/src/mux_demux.c b/src/mux_demux.c index 2971c87..6a7b326 100644 --- a/src/mux_demux.c +++ b/src/mux_demux.c @@ -151,8 +151,7 @@ OSMO_ASSERT(line->mode == E1_LINE_MODE_CHANNELIZED);
/* Scan timeslots */ - for (int tsn=1; tsn<32; tsn++) - { + for (int tsn = 1; tsn < 32; tsn++) { struct e1_ts *ts = &line->ts[tsn]; uint8_t buf_ts[fts]; int l; @@ -164,7 +163,7 @@ if (l <= 0) continue;
- for (int i=0; i<l; i++) + for (int i = 0; i < l; i++) buf[tsn+(i*32)] = buf_ts[i]; } } @@ -327,15 +326,14 @@ { OSMO_ASSERT(line->mode == E1_LINE_MODE_CHANNELIZED);
- for (int tsn=1; tsn<32; tsn++) - { + for (int tsn = 1; tsn < 32; tsn++) { struct e1_ts *ts = &line->ts[tsn]; uint8_t buf_ts[ftr];
if (ts->mode == E1_TS_MODE_OFF) continue;
- for (int i=0; i<ftr; i++) + for (int i = 0; i < ftr; i++) buf_ts[i] = buf[tsn+(i*32)];
_e1_ts_write(ts, buf_ts, ftr); diff --git a/src/usb.c b/src/usb.c index c67f5b9..d36ed42 100644 --- a/src/usb.c +++ b/src/usb.c @@ -185,7 +185,7 @@ /* FIXME: Check transfer status ? Error handling ? */
if (flow->ep & 0x80) { - for (j=0; j<flow->ppx; j++) { + for (j = 0; j < flow->ppx; j++) { flow->cb(flow, libusb_get_iso_packet_buffer_simple(xfr, j), (xfr->iso_packet_desc[j].status == LIBUSB_TRANSFER_COMPLETED) ? @@ -194,7 +194,7 @@ len += (xfr->iso_packet_desc[j].length = flow->size); } } else { - for (j=0; j<flow->ppx; j++) + for (j = 0; j < flow->ppx; j++) len += (xfr->iso_packet_desc[j].length = flow->cb(flow, &xfr->buffer[len], flow->size)); }
@@ -226,7 +226,7 @@ flow->ppx = ppx; flow->entries = talloc_zero_size(ctx, count * sizeof(struct e1_usb_flow_entry));
- for (int i=0; i<count; i++) + for (int i = 0; i < count; i++) flow->entries[i].buf = talloc_zero_size(ctx, size * ppx);
return flow; @@ -239,7 +239,7 @@ return;
/* FIXME: stop pending transfers */ - for (int i=0; i<flow->count; i++) + for (int i = 0; i < flow->count; i++) talloc_free(flow->entries[i].buf);
talloc_free(flow->entries); @@ -253,8 +253,7 @@ struct libusb_transfer *xfr; int i, j, rv, len;
- for (i=0; i<flow->count; i++) - { + for (i = 0; i < flow->count; i++) { xfr = libusb_alloc_transfer(flow->ppx); if (!xfr) return -ENOMEM; @@ -262,10 +261,10 @@ len = 0;
if (flow->ep & 0x80) { - for (j=0; j<flow->ppx; j++) + for (j = 0; j < flow->ppx; j++) len += (xfr->iso_packet_desc[j].length = flow->size); } else { - for (j=0; j<flow->ppx; j++) + for (j = 0; j < flow->ppx; j++) len += (xfr->iso_packet_desc[j].length = flow->cb(flow, &flow->entries[i].buf[len], flow->size)); }
@@ -529,7 +528,7 @@ return ret; }
- for (i=0; i<cd->bNumInterfaces; i++) { + for (i =0; i < cd->bNumInterfaces; i++) { /* Expect 2 altsettings with proper class/subclass/eps */ if (cd->interface[i].num_altsetting != 2) continue; @@ -559,7 +558,7 @@ line_data->r_acc = 0; line_data->r_sw = 8192;
- for (j=0; j<id->bNumEndpoints; j++) { + for (j = 0; j < id->bNumEndpoints; j++) { if (id->endpoint[j].bmAttributes == 0x11) { line_data->ep_fb = id->endpoint[j].bEndpointAddress; } else if (id->endpoint[j].bmAttributes == 0x05) { @@ -623,7 +622,7 @@ return -EIO; }
- for (i=0; i<n_dev; i++) { + for (i = 0; i < n_dev; i++) { struct libusb_device_descriptor desc;
ret = libusb_get_device_descriptor(dev_list[i], &desc);