Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/linux-sunxi/sunxi-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Przywara <osp@andrep.de>2022-02-18 16:37:12 +0300
committerAndre Przywara <osp@andrep.de>2022-02-18 16:47:04 +0300
commit0fc5630f3cab1f7bb5b449429adfcd2b4d21edbf (patch)
tree048936d360ab58a54d8ba49b87ca9f60bc191139
parent08e209122b09f965862a531351feb1a79ebe33e4 (diff)
fel_lib: fix wrong const annotation
The aw_usb_read() function is meant to *fill* the buffer given to it, so marking the pointer as "const" in the parameters list is wrong. Some compilers (for instance GCC 11) spot this and issue a warning: ---------------------------------- fel_lib.c: In function ‘aw_read_fel_status’: fel_lib.c:190:9: warning: ‘buf’ may be used uninitialized [-Wmaybe-uninitialize] 190 | aw_usb_read(dev, buf, sizeof(buf)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fel_lib.c:168:13: note: by argument 2 of type ‘const void *’ to ‘aw_usb_read’ declared here 168 | static void aw_usb_read(feldev_handle *dev, const void *data, size_t len) | ^~~~~~~~~~~ fel_lib.c:189:14: note: ‘buf’ declared here 189 | char buf[8]; | ^~~ ---------------------------------- Drop the 'const' specifier, and use the right USB bulk transfer wrapper to make this work. The usb_bulk_send() function just happened to work before because the actual libusb bulk transfer function is bidirectional. Signed-off-by: Andre Przywara <osp@andrep.de>
-rw-r--r--fel_lib.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fel_lib.c b/fel_lib.c
index 0852cc8..485df2b 100644
--- a/fel_lib.c
+++ b/fel_lib.c
@@ -165,11 +165,10 @@ static void aw_usb_write(feldev_handle *dev, const void *data, size_t len,
aw_read_usb_response(dev);
}
-static void aw_usb_read(feldev_handle *dev, const void *data, size_t len)
+static void aw_usb_read(feldev_handle *dev, void *data, size_t len)
{
aw_send_usb_request(dev, AW_USB_READ, len);
- usb_bulk_send(dev->usb->handle, dev->usb->endpoint_in,
- data, len, false);
+ usb_bulk_recv(dev->usb->handle, dev->usb->endpoint_in, data, len);
aw_read_usb_response(dev);
}