- const struct shash_node **nodes;
- const struct shash *config;
- size_t i;
-
- config = netdev_get_config(netdev);
- nodes = shash_sort(config);
- for (i = 0; i < shash_count(config); i++) {
- const struct shash_node *node = nodes[i];
- printf("%c %s=%s", i ? ',' : ':',
- node->name, (char *) node->data);
+ struct shash config;
+
+ shash_init(&config);
+ error = netdev_get_config(netdev, &config);
+ if (!error) {
+ const struct shash_node **nodes;
+ size_t i;
+
+ nodes = shash_sort(&config);
+ for (i = 0; i < shash_count(&config); i++) {
+ const struct shash_node *node = nodes[i];
+ printf("%c %s=%s", i ? ',' : ':',
+ node->name, (char *) node->data);
+ }
+ free(nodes);
+ } else {
+ printf(", could not retrieve configuration (%s)",
+ strerror(error));