[S] Change in osmo-e1d[master]: usb: Pass not just the actual transfer length but also the buffer size

2023-12-17 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-e1d/+/27578?usp=email )

Change subject: usb: Pass not just the actual transfer length but also the 
buffer size
..

usb: Pass not just the actual transfer length but also the buffer size

Change-Id: I5088a5213d2945fdfaf3b242a63e35d0ed511914
---
M src/usb.c
1 file changed, 18 insertions(+), 7 deletions(-)

Approvals:
  manawyrm: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/src/usb.c b/src/usb.c
index ff624ea..1ff9b43 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -106,7 +106,8 @@
struct libusb_transfer *xfr;
 };

-typedef int (*xfer_cb_t)(struct e1_usb_flow *flow, uint8_t *buf, int len);
+/* len == actual length, size == underlying size of buffer */
+typedef int (*xfer_cb_t)(struct e1_usb_flow *flow, uint8_t *buf, int len, 
size_t size);

 struct e1_usb_flow {
struct e1_line *line;
@@ -126,7 +127,7 @@
 // ---

 static int
-e1_usb_xfer_in(struct e1_usb_flow *flow, uint8_t *buf, int len)
+e1_usb_xfer_in(struct e1_usb_flow *flow, uint8_t *buf, int len, size_t size)
 {
if (len == 0)
return 0;
@@ -134,7 +135,7 @@
 }

 static int
-e1_usb_xfer_out(struct e1_usb_flow *flow, uint8_t *buf, int len)
+e1_usb_xfer_out(struct e1_usb_flow *flow, uint8_t *buf, int len, size_t size)
 {
struct e1_line *line = flow->line;
struct e1_usb_line_data *ld = (struct e1_usb_line_data *) 
line->drv_data;
@@ -163,7 +164,7 @@
 }

 static int
-e1_usb_xfer_fb(struct e1_usb_flow *flow, uint8_t *buf, int len)
+e1_usb_xfer_fb(struct e1_usb_flow *flow, uint8_t *buf, int len, size_t size)
 {
struct e1_usb_line_data *ld = (struct e1_usb_line_data *) 
flow->line->drv_data;

@@ -218,7 +219,8 @@
}
flow->cb(flow,
libusb_get_iso_packet_buffer_simple(xfr, j),
-   (iso_pd->status == LIBUSB_TRANSFER_COMPLETED) ? 
 (int)iso_pd->actual_length : -1
+   (iso_pd->status == LIBUSB_TRANSFER_COMPLETED) ? 
 (int)iso_pd->actual_length : -1,
+   iso_pd->length
);
len += (iso_pd->length = flow->size);
}
@@ -229,7 +231,7 @@
LOGPLI(flow->line, DE1D, LOGL_ERROR, "OUT EP 
%02x ISO packet %d failed with status %s\n",
flow->ep, j, 
get_value_string(libusb_status_str, iso_pd->status));
}
-   len += (iso_pd->length = flow->cb(flow, 
>buffer[len], flow->size));
+   len += (iso_pd->length = flow->cb(flow, 
>buffer[len], flow->size, flow->size));
}
}

@@ -302,7 +304,7 @@
len += (xfr->iso_packet_desc[j].length = 
flow->size);
} else {
for (j = 0; j < flow->ppx; j++)
-   len += (xfr->iso_packet_desc[j].length = 
flow->cb(flow, >entries[i].buf[len], flow->size));
+   len += (xfr->iso_packet_desc[j].length = 
flow->cb(flow, >entries[i].buf[len], flow->size, flow->size));
}

libusb_fill_iso_transfer(xfr, id->devh, flow->ep,

--
To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27578?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I5088a5213d2945fdfaf3b242a63e35d0ed511914
Gerrit-Change-Number: 27578
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: manawyrm 
Gerrit-Reviewer: tnt 
Gerrit-MessageType: merged


[S] Change in osmo-e1d[master]: usb: Pass not just the actual transfer length but also the buffer size

2023-12-17 Thread manawyrm
Attention is currently required from: laforge, tnt.

manawyrm has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-e1d/+/27578?usp=email )

Change subject: usb: Pass not just the actual transfer length but also the 
buffer size
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27578?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I5088a5213d2945fdfaf3b242a63e35d0ed511914
Gerrit-Change-Number: 27578
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: manawyrm 
Gerrit-Reviewer: tnt 
Gerrit-Attention: laforge 
Gerrit-Attention: tnt 
Gerrit-Comment-Date: Sun, 17 Dec 2023 14:10:50 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in osmo-e1d[master]: usb: Pass not just the actual transfer length but also the buffer size

2023-12-17 Thread laforge
Attention is currently required from: tnt.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-e1d/+/27578?usp=email )

Change subject: usb: Pass not just the actual transfer length but also the 
buffer size
..


Patch Set 3:

(1 comment)

Patchset:

PS1:
After a long time of being in review, I'd love to get this finally merged.

> Why is that needed ? I don't see it used in subsequent patches (yet) ?

the next patch in the series uses size.  Not super critical use, but an 
overflow check.

> I'm wondering if 'len' should be ssize_t just for consitency.

consistency with what?  I currently can't see any other use of ssize_t in 
ice1usb other than a local variable in e1_usb_probe. Please explain.



--
To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27578?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I5088a5213d2945fdfaf3b242a63e35d0ed511914
Gerrit-Change-Number: 27578
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: manawyrm 
Gerrit-Reviewer: tnt 
Gerrit-Attention: tnt 
Gerrit-Comment-Date: Sun, 17 Dec 2023 13:29:50 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge 
Comment-In-Reply-To: tnt 
Gerrit-MessageType: comment


[S] Change in osmo-e1d[master]: usb: Pass not just the actual transfer length but also the buffer size

2023-10-30 Thread laforge
laforge has restored this change. ( 
https://gerrit.osmocom.org/c/osmo-e1d/+/27578?usp=email )

Change subject: usb: Pass not just the actual transfer length but also the 
buffer size
..


Restored
--
To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27578?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I5088a5213d2945fdfaf3b242a63e35d0ed511914
Gerrit-Change-Number: 27578
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: manawyrm 
Gerrit-Reviewer: tnt 
Gerrit-MessageType: restore


[S] Change in osmo-e1d[master]: usb: Pass not just the actual transfer length but also the buffer size

2023-03-22 Thread laforge
laforge has abandoned this change. ( 
https://gerrit.osmocom.org/c/osmo-e1d/+/27578 )

Change subject: usb: Pass not just the actual transfer length but also the 
buffer size
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27578
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I5088a5213d2945fdfaf3b242a63e35d0ed511914
Gerrit-Change-Number: 27578
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: manawyrm 
Gerrit-Reviewer: tnt 
Gerrit-MessageType: abandon