darwin: Fix multiplication overflow by better matching type sizes

These multiplication could indeed have overflowed, but now they are
performed with a bigger type, matching the type they are ultimately
stored in.

Fixes all clang-tidy bugprone-implicit-widening-of-multiplication-result
warnings

References #1479
This commit is contained in:
Sean McBride 2024-04-09 13:40:22 -04:00 committed by Tormod Volden
parent 6883f84f93
commit a18a964aba
4 changed files with 4 additions and 5 deletions

View file

@ -5,7 +5,6 @@ bugprone-*,\
-bugprone-assignment-in-if-condition,\
-bugprone-branch-clone,\
-bugprone-easily-swappable-parameters,\
-bugprone-implicit-widening-of-multiplication-result,\
-bugprone-misplaced-widening-cast,\
-bugprone-narrowing-conversions,\
-bugprone-signed-char-misuse,\

View file

@ -388,7 +388,7 @@ static int save_to_file(unsigned char *data)
return -1;
fputs("P5 384 289 255 ", f);
(void)fwrite(data + 64, 1, 384*289, f);
(void)fwrite(data + 64, 1, 384L*289L, f);
fclose(f);
printf("saved image to %s\n", filename);
return 0;

View file

@ -2409,10 +2409,10 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) {
if (LIBUSB_SPEED_FULL == transfer->dev_handle->dev->speed)
/* Full speed */
cInterface->frames[transfer->endpoint] = frame + (UInt32)transfer->num_iso_packets * (1U << (pipe_properties.interval - 1));
cInterface->frames[transfer->endpoint] = frame + (UInt64)transfer->num_iso_packets * (1UL << (pipe_properties.interval - 1));
else
/* High/super speed */
cInterface->frames[transfer->endpoint] = frame + (UInt32)transfer->num_iso_packets * (1U << (pipe_properties.interval - 1)) / 8;
cInterface->frames[transfer->endpoint] = frame + (UInt64)transfer->num_iso_packets * (1UL << (pipe_properties.interval - 1)) / 8;
if (kresult != kIOReturnSuccess) {
usbi_err (TRANSFER_CTX (transfer), "isochronous transfer failed (dir: %s): %s", IS_XFERIN(transfer) ? "In" : "Out",

View file

@ -1 +1 @@
#define LIBUSB_NANO 11920
#define LIBUSB_NANO 11921