mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 23:09:34 +01:00
monitor: Use standard printf modifiers for attribute values
Use PRIu64 etc. macros from inttypes.h so that the code works in every situation, otherwise using %lu for U64 value gives segfault.
This commit is contained in:
parent
09c29ba3e2
commit
89bacdbc08
@ -1171,40 +1171,41 @@ static void print_attributes(int indent, const struct attr_entry *table,
|
|||||||
break;
|
break;
|
||||||
case ATTR_U8:
|
case ATTR_U8:
|
||||||
val8 = *((uint8_t *) NLA_DATA(nla));
|
val8 = *((uint8_t *) NLA_DATA(nla));
|
||||||
print_attr(indent, "%s: %u (0x%02x)", str, val8, val8);
|
print_attr(indent, "%s: %"PRIu8" (0x%02"PRIx8")",
|
||||||
|
str, val8, val8);
|
||||||
if (NLA_PAYLOAD(nla) != 1)
|
if (NLA_PAYLOAD(nla) != 1)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_U16:
|
case ATTR_U16:
|
||||||
val16 = *((uint16_t *) NLA_DATA(nla));
|
val16 = *((uint16_t *) NLA_DATA(nla));
|
||||||
print_attr(indent, "%s: %u (0x%04x)", str,
|
print_attr(indent, "%s: %"PRIu16" (0x%04"PRIx16")",
|
||||||
val16, val16);
|
str, val16, val16);
|
||||||
if (NLA_PAYLOAD(nla) != 2)
|
if (NLA_PAYLOAD(nla) != 2)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_U32:
|
case ATTR_U32:
|
||||||
val32 = *((uint32_t *) NLA_DATA(nla));
|
val32 = *((uint32_t *) NLA_DATA(nla));
|
||||||
print_attr(indent, "%s: %u (0x%08x)", str,
|
print_attr(indent, "%s: %"PRIu32" (0x%08"PRIx32")",
|
||||||
val32, val32);
|
str, val32, val32);
|
||||||
if (NLA_PAYLOAD(nla) != 4)
|
if (NLA_PAYLOAD(nla) != 4)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_U64:
|
case ATTR_U64:
|
||||||
val64 = *((uint64_t *) NLA_DATA(nla));
|
val64 = *((uint64_t *) NLA_DATA(nla));
|
||||||
print_attr(indent, "%s: %lu (0x%016lx)", str,
|
print_attr(indent, "%s: %"PRIu64" (0x%016"PRIx64")",
|
||||||
val64, val64);
|
str, val64, val64);
|
||||||
if (NLA_PAYLOAD(nla) != 8)
|
if (NLA_PAYLOAD(nla) != 8)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_S32:
|
case ATTR_S32:
|
||||||
val_s32 = *((int32_t *) NLA_DATA(nla));
|
val_s32 = *((int32_t *) NLA_DATA(nla));
|
||||||
print_attr(indent, "%s: %d", str, val_s32);
|
print_attr(indent, "%s: %"PRId32, str, val_s32);
|
||||||
if (NLA_PAYLOAD(nla) != 4)
|
if (NLA_PAYLOAD(nla) != 4)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_S64:
|
case ATTR_S64:
|
||||||
val_s64 = *((int64_t *) NLA_DATA(nla));
|
val_s64 = *((int64_t *) NLA_DATA(nla));
|
||||||
print_attr(indent, "%s: %ld", str, val_s64);
|
print_attr(indent, "%s: %"PRId64, str, val_s64);
|
||||||
if (NLA_PAYLOAD(nla) != 4)
|
if (NLA_PAYLOAD(nla) != 4)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
@ -1249,8 +1250,9 @@ static void print_attributes(int indent, const struct attr_entry *table,
|
|||||||
print_attr(indent, "%s: true", str);
|
print_attr(indent, "%s: true", str);
|
||||||
else if (NLA_PAYLOAD(nla) == 2) {
|
else if (NLA_PAYLOAD(nla) == 2) {
|
||||||
val16 = *((uint16_t *) NLA_DATA(nla));
|
val16 = *((uint16_t *) NLA_DATA(nla));
|
||||||
print_attr(indent, "%s: %u (0x%04x)", str,
|
print_attr(indent,
|
||||||
val16, val16);
|
"%s: %"PRIu16" (0x%04"PRIx16")",
|
||||||
|
str, val16, val16);
|
||||||
} else
|
} else
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user