summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2012-10-20 10:20:06 +0000
committered <ed@FreeBSD.org>2012-10-20 10:20:06 +0000
commite65c2d3d073186914cbb3ad3494d5da8b3bde8d5 (patch)
treee44d026c3e12cba359d8412f3c1e41e63e731f60
parentff852f67bd163fdd634ba77c0927e433933e3592 (diff)
downloadFreeBSD-src-e65c2d3d073186914cbb3ad3494d5da8b3bde8d5.zip
FreeBSD-src-e65c2d3d073186914cbb3ad3494d5da8b3bde8d5.tar.gz
Remove redundant code.
Both mfi_flash.c and mfi_show.c contain very similar functions to print a list of firmwares. Move these routines into mfiutil.c. Reported by: jhb
-rw-r--r--usr.sbin/mfiutil/mfi_flash.c32
-rw-r--r--usr.sbin/mfiutil/mfi_show.c28
-rw-r--r--usr.sbin/mfiutil/mfiutil.c30
-rw-r--r--usr.sbin/mfiutil/mfiutil.h5
4 files changed, 35 insertions, 60 deletions
diff --git a/usr.sbin/mfiutil/mfi_flash.c b/usr.sbin/mfiutil/mfi_flash.c
index 2b82529..d640cf7 100644
--- a/usr.sbin/mfiutil/mfi_flash.c
+++ b/usr.sbin/mfiutil/mfi_flash.c
@@ -42,34 +42,6 @@
#define FLASH_BUF_SIZE (64 * 1024)
-static void
-scan_firmware(struct mfi_info_component *comp)
-{
- int len;
-
- len = strlen(comp->name);
- if (fw_name_width < len)
- fw_name_width = len;
- len = strlen(comp->version);
- if (fw_version_width < len)
- fw_version_width = len;
- len = strlen(comp->build_date);
- if (fw_date_width < len)
- fw_date_width = len;
- len = strlen(comp->build_time);
- if (fw_time_width < len)
- fw_time_width = len;
-}
-
-static void
-display_firmware(struct mfi_info_component *comp)
-{
-
- printf("%-*s %-*s %-*s %-*s\n", fw_name_width, comp->name,
- fw_version_width, comp->version, fw_date_width, comp->build_date,
- fw_time_width, comp->build_time);
-}
-
static int
display_pending_firmware(int fd)
{
@@ -94,9 +66,9 @@ display_pending_firmware(int fd)
info.pending_image_component_count = 8;
for (i = 0; i < info.pending_image_component_count; i++)
scan_firmware(&info.pending_image_component[i]);
- display_firmware(&header);
+ display_firmware(&header, "");
for (i = 0; i < info.pending_image_component_count; i++)
- display_firmware(&info.pending_image_component[i]);
+ display_firmware(&info.pending_image_component[i], "");
return (0);
}
diff --git a/usr.sbin/mfiutil/mfi_show.c b/usr.sbin/mfiutil/mfi_show.c
index c8b4377..be395bb 100644
--- a/usr.sbin/mfiutil/mfi_show.c
+++ b/usr.sbin/mfiutil/mfi_show.c
@@ -570,34 +570,6 @@ error:
}
MFI_COMMAND(show, drives, show_drives);
-static void
-scan_firmware(struct mfi_info_component *comp)
-{
- int len;
-
- len = strlen(comp->name);
- if (fw_name_width < len)
- fw_name_width = len;
- len = strlen(comp->version);
- if (fw_version_width < len)
- fw_version_width = len;
- len = strlen(comp->build_date);
- if (fw_date_width < len)
- fw_date_width = len;
- len = strlen(comp->build_time);
- if (fw_time_width < len)
- fw_time_width = len;
-}
-
-static void
-display_firmware(struct mfi_info_component *comp, const char *tag)
-{
-
- printf("%-*s %-*s %-*s %-*s %s\n", fw_name_width, comp->name,
- fw_version_width, comp->version, fw_date_width, comp->build_date,
- fw_time_width, comp->build_time, tag);
-}
-
static int
show_firmware(int ac, char **av __unused)
{
diff --git a/usr.sbin/mfiutil/mfiutil.c b/usr.sbin/mfiutil/mfiutil.c
index b0b6353..79c6a4b 100644
--- a/usr.sbin/mfiutil/mfiutil.c
+++ b/usr.sbin/mfiutil/mfiutil.c
@@ -45,7 +45,7 @@ MFI_TABLE(top, abort);
int mfi_unit;
u_int mfi_opts;
-int fw_name_width, fw_version_width, fw_date_width, fw_time_width;
+static int fw_name_width, fw_version_width, fw_date_width, fw_time_width;
static void
usage(void)
@@ -144,3 +144,31 @@ main(int ac, char **av)
warnx("Unknown command %s.", av[0]);
return (1);
}
+
+void
+scan_firmware(struct mfi_info_component *comp)
+{
+ int len;
+
+ len = strlen(comp->name);
+ if (fw_name_width < len)
+ fw_name_width = len;
+ len = strlen(comp->version);
+ if (fw_version_width < len)
+ fw_version_width = len;
+ len = strlen(comp->build_date);
+ if (fw_date_width < len)
+ fw_date_width = len;
+ len = strlen(comp->build_time);
+ if (fw_time_width < len)
+ fw_time_width = len;
+}
+
+void
+display_firmware(struct mfi_info_component *comp, const char *tag)
+{
+
+ printf("%-*s %-*s %-*s %-*s %s\n", fw_name_width, comp->name,
+ fw_version_width, comp->version, fw_date_width, comp->build_date,
+ fw_time_width, comp->build_time, tag);
+}
diff --git a/usr.sbin/mfiutil/mfiutil.h b/usr.sbin/mfiutil/mfiutil.h
index c696a05..687bdd9 100644
--- a/usr.sbin/mfiutil/mfiutil.h
+++ b/usr.sbin/mfiutil/mfiutil.h
@@ -121,8 +121,8 @@ struct mfiutil_command {
#define MFI_DNAME_HONOR_OPTS 0x8000 /* Allow cmd line to override default */
extern int mfi_unit;
+
extern u_int mfi_opts;
-extern int fw_name_width, fw_version_width, fw_date_width, fw_time_width;
void mbox_store_ldref(uint8_t *mbox, union mfi_ld_ref *ref);
void mbox_store_pdref(uint8_t *mbox, union mfi_pd_ref *ref);
@@ -153,4 +153,7 @@ const char *mfi_status(u_int status_code);
const char *mfi_drive_name(struct mfi_pd_info *pinfo, uint16_t device_id,
uint32_t def);
+void scan_firmware(struct mfi_info_component *comp);
+void display_firmware(struct mfi_info_component *comp, const char *tag);
+
#endif /* !__MFIUTIL_H__ */
OpenPOWER on IntegriCloud