Use if ... else when printing memory attributes
In vmstat there is a switch statement that converts these attributes to a string. As some values can be duplicate we have to hide these from userspace. Replace this switch statement with an if ... else macro that lets us repeat values without a compiler error. Reviewed by: kib MFC after: 2 weeks Sponsored by: ABT Systems Ltd Differential Revision: https://reviews.freebsd.org/D29703
This commit is contained in:
parent
a091c35323
commit
15221c552b
@ -1538,66 +1538,48 @@ display_object(struct kinfo_vmobject *kvo)
|
|||||||
xo_emit("{:inactive/%5ju} ", (uintmax_t)kvo->kvo_inactive);
|
xo_emit("{:inactive/%5ju} ", (uintmax_t)kvo->kvo_inactive);
|
||||||
xo_emit("{:refcount/%3d} ", kvo->kvo_ref_count);
|
xo_emit("{:refcount/%3d} ", kvo->kvo_ref_count);
|
||||||
xo_emit("{:shadowcount/%3d} ", kvo->kvo_shadow_count);
|
xo_emit("{:shadowcount/%3d} ", kvo->kvo_shadow_count);
|
||||||
switch (kvo->kvo_memattr) {
|
|
||||||
|
#define MEMATTR_STR(type, val) \
|
||||||
|
if (kvo->kvo_memattr == (type)) { \
|
||||||
|
str = (val); \
|
||||||
|
} else
|
||||||
#ifdef VM_MEMATTR_UNCACHEABLE
|
#ifdef VM_MEMATTR_UNCACHEABLE
|
||||||
case VM_MEMATTR_UNCACHEABLE:
|
MEMATTR_STR(VM_MEMATTR_UNCACHEABLE, "UC")
|
||||||
str = "UC";
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef VM_MEMATTR_WRITE_COMBINING
|
#ifdef VM_MEMATTR_WRITE_COMBINING
|
||||||
case VM_MEMATTR_WRITE_COMBINING:
|
MEMATTR_STR(VM_MEMATTR_WRITE_COMBINING, "WC")
|
||||||
str = "WC";
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef VM_MEMATTR_WRITE_THROUGH
|
#ifdef VM_MEMATTR_WRITE_THROUGH
|
||||||
case VM_MEMATTR_WRITE_THROUGH:
|
MEMATTR_STR(VM_MEMATTR_WRITE_THROUGH, "WT")
|
||||||
str = "WT";
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef VM_MEMATTR_WRITE_PROTECTED
|
#ifdef VM_MEMATTR_WRITE_PROTECTED
|
||||||
case VM_MEMATTR_WRITE_PROTECTED:
|
MEMATTR_STR(VM_MEMATTR_WRITE_PROTECTED, "WP")
|
||||||
str = "WP";
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef VM_MEMATTR_WRITE_BACK
|
#ifdef VM_MEMATTR_WRITE_BACK
|
||||||
case VM_MEMATTR_WRITE_BACK:
|
MEMATTR_STR(VM_MEMATTR_WRITE_BACK, "WB")
|
||||||
str = "WB";
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef VM_MEMATTR_WEAK_UNCACHEABLE
|
#ifdef VM_MEMATTR_WEAK_UNCACHEABLE
|
||||||
case VM_MEMATTR_WEAK_UNCACHEABLE:
|
MEMATTR_STR(VM_MEMATTR_WEAK_UNCACHEABLE, "UC-")
|
||||||
str = "UC-";
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef VM_MEMATTR_WB_WA
|
#ifdef VM_MEMATTR_WB_WA
|
||||||
case VM_MEMATTR_WB_WA:
|
MEMATTR_STR(VM_MEMATTR_WB_WA, "WB")
|
||||||
str = "WB";
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef VM_MEMATTR_NOCACHE
|
#ifdef VM_MEMATTR_NOCACHE
|
||||||
case VM_MEMATTR_NOCACHE:
|
MEMATTR_STR(VM_MEMATTR_NOCACHE, "NC")
|
||||||
str = "NC";
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef VM_MEMATTR_DEVICE
|
#ifdef VM_MEMATTR_DEVICE
|
||||||
case VM_MEMATTR_DEVICE:
|
MEMATTR_STR(VM_MEMATTR_DEVICE, "DEV")
|
||||||
str = "DEV";
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef VM_MEMATTR_CACHEABLE
|
#ifdef VM_MEMATTR_CACHEABLE
|
||||||
case VM_MEMATTR_CACHEABLE:
|
MEMATTR_STR(VM_MEMATTR_CACHEABLE, "C")
|
||||||
str = "C";
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef VM_MEMATTR_PREFETCHABLE
|
#ifdef VM_MEMATTR_PREFETCHABLE
|
||||||
case VM_MEMATTR_PREFETCHABLE:
|
MEMATTR_STR(VM_MEMATTR_PREFETCHABLE, "PRE")
|
||||||
str = "PRE";
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
default:
|
{
|
||||||
str = "??";
|
str = "??";
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
#undef MEMATTR_STR
|
||||||
xo_emit("{:attribute/%-3s} ", str);
|
xo_emit("{:attribute/%-3s} ", str);
|
||||||
switch (kvo->kvo_type) {
|
switch (kvo->kvo_type) {
|
||||||
case KVME_TYPE_NONE:
|
case KVME_TYPE_NONE:
|
||||||
|
Loading…
Reference in New Issue
Block a user