mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 14:49:24 +01:00
monitor: Use temporary variable for RTA_PAYLOAD
This commit is contained in:
parent
df911c0cf6
commit
60bc0ecf22
@ -4321,8 +4321,6 @@ static void print_rtnl_attributes(int indent, const struct attr_entry *table,
|
|||||||
struct rtattr *rt_attr, int len)
|
struct rtattr *rt_attr, int len)
|
||||||
{
|
{
|
||||||
struct rtattr *attr;
|
struct rtattr *attr;
|
||||||
const char *str;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!table || !rt_attr)
|
if (!table || !rt_attr)
|
||||||
return;
|
return;
|
||||||
@ -4338,6 +4336,8 @@ static void print_rtnl_attributes(int indent, const struct attr_entry *table,
|
|||||||
int8_t val_s8;
|
int8_t val_s8;
|
||||||
int32_t val_s32;
|
int32_t val_s32;
|
||||||
int64_t val_s64;
|
int64_t val_s64;
|
||||||
|
const char *str;
|
||||||
|
int i, payload;
|
||||||
|
|
||||||
str = "Reserved";
|
str = "Reserved";
|
||||||
|
|
||||||
@ -4350,11 +4350,12 @@ static void print_rtnl_attributes(int indent, const struct attr_entry *table,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
payload = RTA_PAYLOAD(attr);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ATTR_CUSTOM:
|
case ATTR_CUSTOM:
|
||||||
if (function)
|
if (function)
|
||||||
function(indent, str, RTA_DATA(attr),
|
function(indent, str, RTA_DATA(attr), payload);
|
||||||
RTA_PAYLOAD(attr));
|
|
||||||
else
|
else
|
||||||
printf("missing function\n");
|
printf("missing function\n");
|
||||||
break;
|
break;
|
||||||
@ -4366,57 +4367,57 @@ static void print_rtnl_attributes(int indent, const struct attr_entry *table,
|
|||||||
val8 = *((uint8_t *) RTA_DATA(attr));
|
val8 = *((uint8_t *) RTA_DATA(attr));
|
||||||
print_attr(indent, "%s: %"PRIu8" (0x%02"PRIx8")", str,
|
print_attr(indent, "%s: %"PRIu8" (0x%02"PRIx8")", str,
|
||||||
val8, val8);
|
val8, val8);
|
||||||
if (RTA_PAYLOAD(attr) != 1)
|
if (payload != 1)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_U16:
|
case ATTR_U16:
|
||||||
val16 = *((uint16_t *) RTA_DATA(attr));
|
val16 = *((uint16_t *) RTA_DATA(attr));
|
||||||
print_attr(indent, "%s: %"PRIu16" (0x%04"PRIx16")", str,
|
print_attr(indent, "%s: %"PRIu16" (0x%04"PRIx16")", str,
|
||||||
val16, val16);
|
val16, val16);
|
||||||
if (RTA_PAYLOAD(attr) != 2)
|
if (payload != 2)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_U32:
|
case ATTR_U32:
|
||||||
val32 = *((uint32_t *) RTA_DATA(attr));
|
val32 = *((uint32_t *) RTA_DATA(attr));
|
||||||
print_attr(indent, "%s: %"PRIu32" (0x%08"PRIx32")", str,
|
print_attr(indent, "%s: %"PRIu32" (0x%08"PRIx32")", str,
|
||||||
val32, val32);
|
val32, val32);
|
||||||
if (RTA_PAYLOAD(attr) != 4)
|
if (payload != 4)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_U64:
|
case ATTR_U64:
|
||||||
val64 = *((uint64_t *) RTA_DATA(attr));
|
val64 = *((uint64_t *) RTA_DATA(attr));
|
||||||
print_attr(indent, "%s: %"PRIu64" (0x%016"PRIx64")",
|
print_attr(indent, "%s: %"PRIu64" (0x%016"PRIx64")",
|
||||||
str, val64, val64);
|
str, val64, val64);
|
||||||
if (RTA_PAYLOAD(attr) != 8)
|
if (payload != 8)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_S8:
|
case ATTR_S8:
|
||||||
val_s8 = *((int8_t *) RTA_DATA(attr));
|
val_s8 = *((int8_t *) RTA_DATA(attr));
|
||||||
print_attr(indent, "%s: %"PRId8, str, val_s8);
|
print_attr(indent, "%s: %"PRId8, str, val_s8);
|
||||||
if (RTA_PAYLOAD(attr) != 1)
|
if (payload != 1)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_S32:
|
case ATTR_S32:
|
||||||
val_s32 = *((int32_t *) RTA_DATA(attr));
|
val_s32 = *((int32_t *) RTA_DATA(attr));
|
||||||
print_attr(indent, "%s: %"PRId32, str, val_s32);
|
print_attr(indent, "%s: %"PRId32, str, val_s32);
|
||||||
if (RTA_PAYLOAD(attr) != 4)
|
if (payload != 4)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_S64:
|
case ATTR_S64:
|
||||||
val_s64 = *((int64_t *) RTA_DATA(attr));
|
val_s64 = *((int64_t *) RTA_DATA(attr));
|
||||||
print_attr(indent, "%s: %"PRId64, str, val_s64);
|
print_attr(indent, "%s: %"PRId64, str, val_s64);
|
||||||
if (RTA_PAYLOAD(attr) != 8)
|
if (payload != 8)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_FLAG:
|
case ATTR_FLAG:
|
||||||
print_attr(indent, "%s: true", str);
|
print_attr(indent, "%s: true", str);
|
||||||
if (RTA_PAYLOAD(attr) != 0)
|
if (payload != 0)
|
||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_FLAG_OR_U16:
|
case ATTR_FLAG_OR_U16:
|
||||||
if (RTA_PAYLOAD(attr) == 0)
|
if (payload == 0)
|
||||||
print_attr(indent, "%s: true", str);
|
print_attr(indent, "%s: true", str);
|
||||||
else if (RTA_PAYLOAD(attr) == 2) {
|
else if (payload == 2) {
|
||||||
val16 = *((uint16_t *) RTA_DATA(attr));
|
val16 = *((uint16_t *) RTA_DATA(attr));
|
||||||
print_attr(indent,
|
print_attr(indent,
|
||||||
"%s: %"PRIu16" (0x%04"PRIx16")",
|
"%s: %"PRIu16" (0x%04"PRIx16")",
|
||||||
@ -4425,17 +4426,14 @@ static void print_rtnl_attributes(int indent, const struct attr_entry *table,
|
|||||||
printf("malformed packet\n");
|
printf("malformed packet\n");
|
||||||
break;
|
break;
|
||||||
case ATTR_BINARY:
|
case ATTR_BINARY:
|
||||||
print_attr(indent, "%s: len %lu", str,
|
print_attr(indent, "%s: len %d", str, payload);
|
||||||
RTA_PAYLOAD(attr));
|
print_hexdump(indent + 1, RTA_DATA(attr), payload);
|
||||||
print_hexdump(indent + 1,
|
|
||||||
RTA_DATA(attr), RTA_PAYLOAD(attr));
|
|
||||||
break;
|
break;
|
||||||
case ATTR_ADDRESS:
|
case ATTR_ADDRESS:
|
||||||
case ATTR_NESTED:
|
case ATTR_NESTED:
|
||||||
case ATTR_ARRAY:
|
case ATTR_ARRAY:
|
||||||
case ATTR_UNSPEC:
|
case ATTR_UNSPEC:
|
||||||
print_attr(indent, "%s: len %lu", str,
|
print_attr(indent, "%s: len %d", str, payload);
|
||||||
RTA_PAYLOAD(attr));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user