diff options
author | James C. McPherson <James.McPherson@Sun.COM> | 2008-08-12 21:15:45 -0700 |
---|---|---|
committer | James C. McPherson <James.McPherson@Sun.COM> | 2008-08-12 21:15:45 -0700 |
commit | f1c2346531c82ed357422b37e6c09f7b692e0c45 (patch) | |
tree | 935ef6719eec030c3d9245726d693be6af475186 /usr/src | |
parent | f0a5c2e3fe8604dab68634890fee7db5142bc607 (diff) | |
download | illumos-joyent-f1c2346531c82ed357422b37e6c09f7b692e0c45.tar.gz |
6734095 fwflash lint cleanup (common code and ses/sgen plugins)
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/fwflash/Makefile.com | 8 | ||||
-rw-r--r-- | usr/src/cmd/fwflash/common/fwflash.c | 115 | ||||
-rw-r--r-- | usr/src/cmd/fwflash/common/fwflash.h | 24 | ||||
-rw-r--r-- | usr/src/cmd/fwflash/plugins/transport/common/ses.c | 20 |
4 files changed, 28 insertions, 139 deletions
diff --git a/usr/src/cmd/fwflash/Makefile.com b/usr/src/cmd/fwflash/Makefile.com index 9b9a066e9e..e0f1c58ec2 100644 --- a/usr/src/cmd/fwflash/Makefile.com +++ b/usr/src/cmd/fwflash/Makefile.com @@ -21,8 +21,6 @@ # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -#ident "%Z%%M% %I% %E% SMI" -# # cmd/fwflash/Makefile.com # # @@ -85,7 +83,5 @@ BUILD.SO= $(CC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(LDLIBS) POST_PROCESS_O += ; $(CTFCONVERT_POST) POST_PROCESS_SO += ; $(CTFMERGE_POST) -LINTFLAGS += -erroff=E_CONSTANT_CONDITION -D_POSIX_PTHREAD_SEMANTICS \ - -erroff=E_CONST_TRUNCATED_BY_ASSIGN \ - -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED \ - -erroff=E_BAD_PTR_CAST_ALIGN +LINTFLAGS += -D_POSIX_PTHREAD_SEMANTICS -erroff=E_CONSTANT_CONDITION \ + -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED diff --git a/usr/src/cmd/fwflash/common/fwflash.c b/usr/src/cmd/fwflash/common/fwflash.c index 845c2b23be..fdf07ca885 100644 --- a/usr/src/cmd/fwflash/common/fwflash.c +++ b/usr/src/cmd/fwflash/common/fwflash.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * fwflash.c */ @@ -32,7 +30,6 @@ #include <stdlib.h> #include <unistd.h> #include <strings.h> -#include <ctype.h> #include <errno.h> #include <sys/queue.h> #include <signal.h> @@ -43,11 +40,9 @@ #include <fcntl.h> #include <dlfcn.h> #include <dirent.h> -#include <link.h> #include <sys/varargs.h> #include <libintl.h> /* for gettext(3c) */ #include <libdevinfo.h> -#include <note.h> #include <fwflash/fwflash.h> #include <sys/modctl.h> /* for MAXMODCONFNAME */ @@ -77,7 +72,6 @@ static char *sla [] = { "Copyright 2007 Sun Microsystems, Inc., 4150 Network " int fwflash_arg_list = 0; char *filelist[10]; - /* are we writing to flash? */ static int fwflash_in_write = 0; @@ -85,15 +79,13 @@ static int fwflash_in_write = 0; * If we *must* track the version string for fwflash, then * we should do so in this common file rather than the header * file since it will then be in sync with what the customer - * sees + * sees. We should deprecate the "-v" option since it is not + * actually of any use - it doesn't line up with Mercurial's + * concept of the changeset. */ - - -#define FWFLASH_VERSION "%I%" +#define FWFLASH_VERSION "v1.6" #define FWFLASH_PROG_NAME "fwflash" - - static int get_fileopts(char *options); static int flash_device_list(); static int flash_load_plugins(); @@ -103,14 +95,10 @@ static int fwflash_list_fw(char *class); static int fwflash_load_verifier(char *drv, char *vendorid, char *fwimg); static void fwflash_intr(int sig); static void fwflash_handle_signals(void); -static void fwflash_usage(); -static void fwflash_help(void); +static void fwflash_usage(char *arg); static void fwflash_version(void); static int confirm_target(struct devicelist *thisdev, char *file); - - - /* * FWFlash main code */ @@ -124,8 +112,6 @@ main(int argc, char **argv) { char *devclass = NULL; char *devpath = NULL; - - /* local variables from env */ (void) setlocale(LC_ALL, ""); @@ -135,7 +121,6 @@ main(int argc, char **argv) { (void) textdomain(TEXT_DOMAIN); - read_file = NULL; if (argc < 2) { @@ -144,49 +129,40 @@ main(int argc, char **argv) { return (FWFLASH_FAILURE); } - while ((ch = getopt(argc, argv, "hvylc:f:r:Qd:M")) != EOF) { switch (ch) { case 'h': fwflash_arg_list |= FWFLASH_HELP_FLAG; break; - case 'v': fwflash_arg_list |= FWFLASH_VER_FLAG; break; - case 'y': fwflash_arg_list |= FWFLASH_YES_FLAG; break; - case 'l': fwflash_arg_list |= FWFLASH_LIST_FLAG; break; - case 'c': fwflash_arg_list |= FWFLASH_CLASS_FLAG; /* we validate later */ devclass = strdup(optarg); break; - case 'd': fwflash_arg_list |= FWFLASH_DEVICE_FLAG; devpath = strdup(optarg); break; - case 'f': fwflash_arg_list |= FWFLASH_FW_FLAG; if ((rv = get_fileopts(optarg)) != FWFLASH_SUCCESS) { - fwflash_help(); + fwflash_usage(NULL); return (FWFLASH_FAILURE); } break; - case 'r': fwflash_arg_list |= FWFLASH_READ_FLAG; read_file = strdup(optarg); break; - case 'Q': /* NOT in the manpage */ fwflash_debug = 1; @@ -211,7 +187,7 @@ main(int argc, char **argv) { ((fwflash_arg_list & FWFLASH_DEVICE_FLAG) && !((fwflash_arg_list & FWFLASH_FW_FLAG) || (fwflash_arg_list & FWFLASH_READ_FLAG)))) { - fwflash_help(); + fwflash_usage(NULL); return (FWFLASH_SUCCESS); } @@ -282,9 +258,6 @@ main(int argc, char **argv) { } - - - static int flash_load_plugins() { @@ -302,7 +275,6 @@ flash_load_plugins() { (void) dlclose(tmpplug->handle); \ free(tmpplug); } - /* * Procedure: * @@ -361,7 +333,6 @@ flash_load_plugins() { return (FWFLASH_FAILURE); } - NOTE(CONSTCOND) TAILQ_INIT(fw_pluginlist); while ((readdir_r(dirp, plugdir, &plugdir) == 0) && (plugdir != NULL)) { @@ -513,7 +484,6 @@ flash_load_plugins() { return (FWFLASH_FAILURE); } - if (errno != 0) { logmsg(MSG_ERROR, gettext("Error reading directory entry in %s\n"), @@ -528,8 +498,6 @@ flash_load_plugins() { return (rval); } - - /* * fwflash_load_verifier dlload()s the appropriate firmware image * verification plugin, and attaches the designated fwimg's fd to @@ -547,7 +515,6 @@ fwflash_load_verifier(char *drv, char *vendorid, char *fwimg) { struct vrfyplugin *vrfy; void *vrfysym; - /* * To make flashing multiple firmware images somewhat more * efficient, we start this function by checking whether a @@ -771,8 +738,6 @@ cleanup: return (rv); } - - /* * cycles through the global list of plugins to find * each flashable device, which is added to fw_devices @@ -792,7 +757,6 @@ flash_device_list() int sumrv = 0; struct pluginlist *plugins; - /* we open rootnode here, and close it in fwflash_intr */ if ((rootnode = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) { logmsg(MSG_ERROR, @@ -838,9 +802,6 @@ flash_device_list() return (rv); } - - - static int fwflash_list_fw(char *class) { @@ -848,7 +809,6 @@ fwflash_list_fw(char *class) struct devicelist *curdev; int header = 1; - TAILQ_FOREACH(curdev, fw_devices, nextdev) { /* we're either class-conscious, or we're not */ @@ -872,15 +832,12 @@ fwflash_list_fw(char *class) rv += curdev->plugin->fw_devinfo(curdev); } } - - return (rv); } - static int -fwflash_update(char *device, char *filename, int flags) { - +fwflash_update(char *device, char *filename, int flags) +{ int rv = FWFLASH_FAILURE; int needsfree = 0; @@ -888,7 +845,6 @@ fwflash_update(char *device, char *filename, int flags) { struct devicelist *curdev; char *realfile; - /* * Here's how we operate: * @@ -901,10 +857,8 @@ fwflash_update(char *device, char *filename, int flags) { * There is no "force" flag to enable you to flash a firmware * image onto an incompatible device because the verifier * will return FWFLASH_FAILURE if the image doesn't match. - * */ - /* new firmware filename and device desc */ if (filename == NULL) { logmsg(MSG_ERROR, @@ -921,8 +875,8 @@ fwflash_update(char *device, char *filename, int flags) { if ((realfile = calloc(1, PATH_MAX + 1)) == NULL) { logmsg(MSG_ERROR, gettext("Unable to allocate space for device " - "filename, operation might fail if %s is" - "a symbolic link\n"), + "filename, operation might fail if %s is" + "a symbolic link\n"), device); realfile = device; } else { @@ -933,7 +887,7 @@ fwflash_update(char *device, char *filename, int flags) { if (realpath(device, realfile) == NULL) { logmsg(MSG_ERROR, gettext("Unable to resolve device filename" - ": %s\n"), + ": %s\n"), strerror(errno)); /* tidy up */ free(realfile); @@ -957,7 +911,7 @@ fwflash_update(char *device, char *filename, int flags) { if (rv == FWFLASH_FAILURE) { logmsg(MSG_ERROR, gettext("Unable to load verifier " - "for device %s\n"), + "for device %s\n"), curdev->access_devname); return (FWFLASH_FAILURE); } @@ -972,7 +926,7 @@ fwflash_update(char *device, char *filename, int flags) { return (rv); } - if ((flags == FWFLASH_YES_FLAG) || + if (((flags & FWFLASH_YES_FLAG) == FWFLASH_YES_FLAG) || (rv = confirm_target(curdev, filename)) == FWFLASH_YES_FLAG) { logmsg(MSG_INFO, @@ -983,15 +937,15 @@ fwflash_update(char *device, char *filename, int flags) { if (rv == FWFLASH_FAILURE) { logmsg(MSG_ERROR, gettext("Failed to flash " - "firmware file %s on " - "device %s: %d\n"), + "firmware file %s on " + "device %s: %d\n"), filename, curdev->access_devname, rv); } } else { logmsg(MSG_ERROR, gettext("Flash operation not confirmed " - "by user\n"), + "by user\n"), curdev->access_devname); rv = FWFLASH_FAILURE; } @@ -1016,7 +970,6 @@ fwflash_update(char *device, char *filename, int flags) { * We validate that the device path is in our global device list and * that the filename exists, then palm things off to the relevant plugin. */ - static int fwflash_read_file(char *device, char *filename) { @@ -1094,34 +1047,18 @@ fwflash_usage(char *arg) "\tthey must be listed together, separated by commas. The\n" "\timages will be flashed in the order specified.\n\n")); - (void) fprintf(stdout, "\n"); } - - - - - - static void fwflash_version(void) { (void) fprintf(stdout, gettext("\n%s: "), FWFLASH_PROG_NAME); (void) fprintf(stdout, gettext("version %s\n"), FWFLASH_VERSION); - - } static void -fwflash_help(void) -{ - fwflash_usage(NULL); -} - -/* ARGSUSED */ -static void fwflash_intr(int sig) { @@ -1149,9 +1086,7 @@ fwflash_intr(int sig) * we need to close everything down properly, so * call the plugin closure routines */ - if (fw_devices != NULL) { - TAILQ_FOREACH(thisdev, fw_devices, nextdev) { /* free the components first */ free(thisdev->access_devname); @@ -1167,9 +1102,7 @@ fwflash_intr(int sig) } } - if (fw_pluginlist != NULL) { - TAILQ_FOREACH(thisplug, fw_pluginlist, nextplugin) { free(thisplug->filename); free(thisplug->drvname); @@ -1189,11 +1122,9 @@ fwflash_intr(int sig) thisplug->plugin = NULL; /* CONSTCOND */ TAILQ_REMOVE(fw_pluginlist, thisplug, nextplugin); - } } - if (verifier != NULL) { free(verifier->filename); free(verifier->vendor); @@ -1208,7 +1139,6 @@ fwflash_intr(int sig) verifier->handle = NULL; free(verifier); } - di_fini(rootnode); } @@ -1232,7 +1162,6 @@ confirm_target(struct devicelist *thisdev, char *file) int resp; (void) fflush(stdin); - (void) printf(gettext("About to update firmware on %s\n"), thisdev->access_devname); (void) printf(gettext("with file %s. Do you want to continue? " @@ -1246,7 +1175,6 @@ confirm_target(struct devicelist *thisdev, char *file) } (void) fflush(stdin); - return (FWFLASH_FAILURE); } @@ -1257,7 +1185,6 @@ get_fileopts(char *options) int i; char *files; - if (files = strtok(options, ",")) { /* we have more than one */ if ((filelist[0] = calloc(1, MAXPATHLEN + 1)) == NULL) { @@ -1299,26 +1226,20 @@ get_fileopts(char *options) filelist[0]); } return (FWFLASH_SUCCESS); - } - - /* * code reuse - cheerfully borrowed from stmsboot_util.c */ void -logmsg(int severity, char *msg, ...) { +logmsg(int severity, const char *msg, ...) { va_list ap; - if ((severity > MSG_INFO) || ((severity == MSG_INFO) && (fwflash_debug > 0))) { - (void) fprintf(stderr, "%s: ", FWFLASH_PROG_NAME); va_start(ap, msg); - /* LINTED - format specifier */ (void) vfprintf(stderr, msg, ap); va_end(ap); } diff --git a/usr/src/cmd/fwflash/common/fwflash.h b/usr/src/cmd/fwflash/common/fwflash.h index b514a700be..e3c4dddbb4 100644 --- a/usr/src/cmd/fwflash/common/fwflash.h +++ b/usr/src/cmd/fwflash/common/fwflash.h @@ -26,8 +26,6 @@ #ifndef _FWFLASH_H #define _FWFLASH_H -#pragma ident "%Z%%M% %I% %E% SMI" - /* * fwflash.h */ @@ -50,7 +48,6 @@ int fwflash_debug; #define FWFLASH_FLASH_IMAGES 2 - #define FWPLUGINDIR "/usr/lib/fwflash/identify" #define FWVERIFYPLUGINDIR "/usr/lib/fwflash/verify" @@ -64,7 +61,6 @@ int fwflash_debug; struct devicelist; struct fw_plugin { - /* * An opaque handle for dlopen()/dlclose() to use. */ @@ -95,7 +91,6 @@ struct fw_plugin { */ int (*fw_readfw)(struct devicelist *device, char *filename); - /* * Function entry point to support the command-line "-f" * option - writes from persistent storage to device @@ -104,7 +99,6 @@ struct fw_plugin { */ int (*fw_writefw)(struct devicelist *device, char *filename); - /* * Function entry point used to build the list of valid, flashable * devices attached to the system using the loadable module drvname. @@ -157,7 +151,6 @@ struct pluginlist { TAILQ_ENTRY(pluginlist) nextplugin; }; - struct vpr { /* vendor ID, eg "HITACHI " */ char *vid; @@ -177,9 +170,6 @@ struct vpr { void *encap_ident; }; - - - struct fwfile { /* * The fully qualified filename. No default location for @@ -194,8 +184,6 @@ struct fwfile { struct vpr *ident; }; - - struct devicelist { /* * fully qualified pathname, with /devices/.... prefix @@ -257,7 +245,6 @@ struct devicelist { */ struct vrfyplugin { - /* * fully-qualified filename in /usr/lib/fwflash/verify, * made up of [drivername]-[vendorname].so @@ -330,8 +317,6 @@ struct vrfyplugin { int (*vendorvrfy)(struct devicelist *devicenode); }; - - /* Flags for argument parsing */ #define FWFLASH_HELP_FLAG 0x01 #define FWFLASH_VER_FLAG 0x02 @@ -343,18 +328,15 @@ struct vrfyplugin { #define FWFLASH_READ_FLAG 0x80 /* global variables for fwflash */ - TAILQ_HEAD(PLUGINLIST, pluginlist); TAILQ_HEAD(DEVICELIST, devicelist); struct PLUGINLIST *fw_pluginlist; struct DEVICELIST *fw_devices; - struct vrfyplugin *verifier; di_node_t rootnode; struct fw_plugin *self; - int manufacturing_mode = 0; /* @@ -370,7 +352,6 @@ int manufacturing_mode = 0; #define LOWBITS32 0x0000ffff #define LOWBITS64 0x00000000ffffffffULL - #if defined(_LITTLE_ENDIAN) #define ARMSWAPBITS(bs) (bs) #define MLXSWAPBITS16(bs) \ @@ -387,11 +368,8 @@ int manufacturing_mode = 0; #endif - /* common functions for fwflash */ - -void logmsg(int severity, char *msg, ...); - +void logmsg(int severity, const char *msg, ...); #ifdef __cplusplus } diff --git a/usr/src/cmd/fwflash/plugins/transport/common/ses.c b/usr/src/cmd/fwflash/plugins/transport/common/ses.c index ff489c0c74..738b89eefc 100644 --- a/usr/src/cmd/fwflash/plugins/transport/common/ses.c +++ b/usr/src/cmd/fwflash/plugins/transport/common/ses.c @@ -23,25 +23,19 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * ses (SCSI Generic Device) specific functions. */ - -#include <assert.h> #include <libnvpair.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> -#include <sys/stat.h> #include <sys/sysmacros.h> #include <sys/queue.h> #include <fcntl.h> #include <string.h> -#include <strings.h> #include <scsi/libscsi.h> #include <scsi/libses.h> #include <libintl.h> /* for gettext(3c) */ @@ -302,7 +296,7 @@ fw_identify(int start) char *devsuffix; char *driver; int idx = start; - int devlength = 0; + size_t devlength = 0; nvlist_t *props; ses_snap_t *snapshot; ses_node_t *rootnodep, *nodep; @@ -321,7 +315,7 @@ fw_identify(int start) if (thisnode == DI_NODE_NIL) { logmsg(MSG_INFO, gettext("No %s nodes in this system\n"), driver); - return (rv); + return (FWFLASH_FAILURE); } if ((devpath = calloc(1, MAXPATHLEN + 1)) == NULL) { @@ -329,7 +323,7 @@ fw_identify(int start) gettext("%s: Unable to allocate space " "for a device node\n"), driver); - return (rv); + return (FWFLASH_FAILURE); } /* we've found one, at least */ @@ -345,7 +339,7 @@ fw_identify(int start) "to allocate space for device entry\n"), driver); free(devpath); - return (rv); + return (FWFLASH_FAILURE); } /* calloc enough for /devices + devpath + devsuffix + '\0' */ @@ -497,9 +491,9 @@ fw_identify(int start) } - if (di_prop_lookup_strings(DDI_DEV_T_ANY, - thisnode, "target-port", - &newdev->addresses[1]) < 0) { + rv = di_prop_lookup_strings(DDI_DEV_T_ANY, + thisnode, "target-port", &newdev->addresses[1]); + if (rv < 0) { logmsg(MSG_INFO, "%s: no target-port property " "for device %s\n", |