return "unknown";
}
+static void
+free_attr_val(const struct switch_attr *attr, const struct switch_val *val)
+{
+ switch (attr->type) {
+ case SWITCH_TYPE_STRING:
+ free(val->value.s);
+ break;
+ case SWITCH_TYPE_PORTS:
+ free(val->value.ports);
+ break;
+ case SWITCH_TYPE_LINK:
+ free(val->value.link);
+ break;
+ default:
+ break;
+ }
+}
+
static void
print_attr_val(const struct switch_attr *attr, const struct switch_val *val)
{
printf("\t%s: ", attr->name);
if (swlib_get_attr(dev, attr, val) < 0)
printf("???");
- else
+ else {
print_attr_val(attr, val);
+ free_attr_val(attr, val);
+ }
putchar('\n');
}
attr = attr->next;
goto out;
}
print_attr_val(a, &val);
+ free_attr_val(a, &val);
putchar('\n');
break;
case CMD_LOAD: