Skip to content

Conversation

@igoropaniuk
Copy link
Contributor

No description provided.

Address always false warning ([-Wtype-limits]):
../vip.c:430:15: warning: comparison of unsigned expression in ‘< 0’ is
  always false [-Wtype-limits]
  430 |         if (n < 0) {
      |               ^
../vip.c:437:15: warning: comparison of unsigned expression in ‘< 0’
  is always false [-Wtype-limits]
  437 |         if (n < 0) {

Signed-off-by: Igor Opaniuk <[email protected]>
Address warnings for comparisons of integer expressions of different
signedness, for example:

../firehose.c:384:31: warning: comparison of integer expressions of
   different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
  384 |                 for (i = 0; i < ARRAY_SIZE(sector_sizes); i++) {

In all places, where signed value is casted to unsigned (size_t for
instance), there is always explicitly handling of possible negative
value beforehand

Signed-off-by: Igor Opaniuk <[email protected]>
@igoropaniuk igoropaniuk changed the title Housekeeping: Integer-related compiler warning [housekeeping] Integer-related compiler warnings Nov 25, 2025
}

if (n < qdl->max_payload_size)
if ((size_t)n < qdl->max_payload_size)
Copy link
Contributor Author

@igoropaniuk igoropaniuk Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the check of n < 0 is above, so safe to cast here

} else if (expect_empty) {
err(1, "expected empty transfer but received non-empty transfer during read");
} else if (n != chunk_size * sector_size) {
} else if ((size_t)n != chunk_size * sector_size) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the check of n < 0 is above, so safe to cast here


if (out_buf) {
if (n > out_len - out_offset)
if ((size_t)n > out_len - out_offset)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the check of n < 0 is already above, so safe to cast here


pkt = (struct sahara_pkt *)buf;
if (n != pkt->length) {
if ((uint32_t)n != pkt->length) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the check of n < 0 is already above, so safe to cast here

@andersson andersson merged commit 2db10bd into linux-msm:master Nov 26, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants