X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=miscutils%2Fdevfsd.c;h=f99a9462892b7f8188d4c269d295d4b36bf2c116;hb=2c99851181a652358aa3ca58ef38c57e46ae02e4;hp=d8a630c043e7310b45d16d368cf97611d682a6d5;hpb=c1ef7bdd8d002ae0889efcf883d0e1b7faa938d4;p=oweals%2Fbusybox.git diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index d8a630c04..f99a94628 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c @@ -476,7 +476,8 @@ int devfsd_main (int argc, char **argv) if (fcntl (fd, F_SETFD, FD_CLOEXEC) != 0) devfsd_perror_msg_and_die("FD_CLOEXEC"); - do_ioctl_and_die(fd, DEVFSDIOC_GET_PROTO_REV,(int )&proto_rev); + if (ioctl (fd, DEVFSDIOC_GET_PROTO_REV, &proto_rev) == -1) + msg_logger_and_die(LOG_ERR, "ioctl"); /*setup initial entries */ for (curr = initial_symlinks; curr->dest != NULL; ++curr) @@ -605,17 +606,18 @@ static void process_config_line (const char *line, unsigned long *event_mask) char name[STRING_LENGTH]; char * msg=""; char *ptr; + int i; /* !!!! Only Uppercase Keywords in devsfd.conf */ - const char *options[] = { "CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE", - "PERMISSIONS", "MODLOAD", "EXECUTE", "COPY", "IGNORE", - "MKOLDCOMPAT", "MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT", 0 }; - - int i; + static const char *const options[] = { + "CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", + "RESTORE", "PERMISSIONS", "MODLOAD", "EXECUTE", + "COPY", "IGNORE", "MKOLDCOMPAT", "MKNEWCOMPAT", + "RMOLDCOMPAT", "RMNEWCOMPAT", 0 + }; debug_msg_logger(LOG_INFO, __FUNCTION__); - for (count = 0; count < MAX_ARGS; ++count) p[count][0] = '\0'; num_args = sscanf (line, "%s %s %s %s %s %s %s %s %s %s", when, name, what, @@ -677,7 +679,7 @@ static void process_config_line (const char *line, unsigned long *event_mask) if ( ( ptr = strchr (p[0], '.') ) == NULL ) { msg="UID.GID"; - goto process_config_line_err; /*"missing '.' in UID.GID */ + goto process_config_line_err; /*"missing '.' in UID.GID"*/ } *ptr++ = '\0'; @@ -870,7 +872,7 @@ static void action_permissions (const struct devfsd_notify_struct *info, } /* End Function action_permissions */ static void action_modload (const struct devfsd_notify_struct *info, - const struct config_entry_struct *entry) + const struct config_entry_struct *entry ATTRIBUTE_UNUSED) /* [SUMMARY] Load a module. The devfs change. The config file entry. @@ -992,17 +994,19 @@ static void action_compat (const struct devfsd_notify_struct *info, unsigned int unsigned int i; char rewind_; /* 1 to 5 "scsi/" , 6 to 9 "ide/host" */ - const char *fmt[] = { NULL , - "sg/c%db%dt%du%d", /* scsi/generic */ - "sd/c%db%dt%du%d", /* scsi/disc */ - "sr/c%db%dt%du%d", /* scsi/cd */ - "sd/c%db%dt%du%dp%d", /* scsi/part */ - "st/c%db%dt%du%dm%d%c", /* scsi/mt */ - "ide/hd/c%db%dt%du%d", /* ide/host/disc */ - "ide/cd/c%db%dt%du%d", /* ide/host/cd */ - "ide/hd/c%db%dt%du%dp%d", /* ide/host/part */ - "ide/mt/c%db%dt%du%d%s", /* ide/host/mt */ - NULL }; + static const char *const fmt[] = { + NULL , + "sg/c%db%dt%du%d", /* scsi/generic */ + "sd/c%db%dt%du%d", /* scsi/disc */ + "sr/c%db%dt%du%d", /* scsi/cd */ + "sd/c%db%dt%du%dp%d", /* scsi/part */ + "st/c%db%dt%du%dm%d%c", /* scsi/mt */ + "ide/hd/c%db%dt%du%d", /* ide/host/disc */ + "ide/cd/c%db%dt%du%d", /* ide/host/cd */ + "ide/hd/c%db%dt%du%dp%d", /* ide/host/part */ + "ide/mt/c%db%dt%du%d%s", /* ide/host/mt */ + NULL + }; /* First construct compatibility name */ switch (action) @@ -1595,20 +1599,22 @@ const char *get_old_name (const char *devname, unsigned int namelen, const char *pty2; size_t len; /* 1 to 5 "scsi/" , 6 to 9 "ide/host", 10 sbp/, 11 vcc/, 12 pty/ */ - const char *fmt[] = { NULL , - "sg%u", /* scsi/generic */ - NULL, /* scsi/disc */ - "sr%u", /* scsi/cd */ - NULL, /* scsi/part */ - "nst%u%c", /* scsi/mt */ - "hd%c" , /* ide/host/disc */ - "hd%c" , /* ide/host/cd */ - "hd%c%s", /* ide/host/part */ - "%sht%d", /* ide/host/mt */ - "sbpcd%u", /* sbp/ */ - "vcs%s", /* vcc/ */ - "%cty%c%c", /* pty/ */ - NULL }; + static const char *const fmt[] = { + NULL , + "sg%u", /* scsi/generic */ + NULL, /* scsi/disc */ + "sr%u", /* scsi/cd */ + NULL, /* scsi/part */ + "nst%u%c", /* scsi/mt */ + "hd%c" , /* ide/host/disc */ + "hd%c" , /* ide/host/cd */ + "hd%c%s", /* ide/host/part */ + "%sht%d", /* ide/host/mt */ + "sbpcd%u", /* sbp/ */ + "vcs%s", /* vcc/ */ + "%cty%c%c", /* pty/ */ + NULL + }; debug_msg_logger(LOG_INFO, __FUNCTION__); @@ -1704,7 +1710,7 @@ static char get_old_ide_name (unsigned int major, unsigned int minor) i==IDE6_MAJOR || i==IDE7_MAJOR || i==IDE8_MAJOR || i==IDE9_MAJOR ) { - if(i==major) + if((unsigned int)i==major) { letter=c; break; @@ -1900,7 +1906,7 @@ static const char *expand_variable (char *buffer, unsigned int length, for (ptr = input; isalnum (ch) || (ch == '_') || (ch == ':');ch = *++ptr) /* VOID */ ; len = ptr - input; - if (len >= sizeof tmp) + if ((size_t)len >= sizeof tmp) goto expand_variable_out; safe_memcpy (tmp, input, len); @@ -1926,7 +1932,7 @@ static const char *expand_variable (char *buffer, unsigned int length, { /* Must be simple variable expansion with "${var}" */ len = ptr - input; - if (len >= sizeof tmp) + if ((size_t)len >= sizeof tmp) goto expand_variable_out; safe_memcpy (tmp, input, len); @@ -1942,7 +1948,7 @@ static const char *expand_variable (char *buffer, unsigned int length, } /* It's that handy "${var:-word}" expression. Check if var is defined */ len = ptr - input; - if (len >= sizeof tmp) + if ((size_t)len >= sizeof tmp) goto expand_variable_out; safe_memcpy (tmp, input, len); @@ -1987,7 +1993,7 @@ static const char *expand_variable (char *buffer, unsigned int length, pointer to start of word in "${var:-word}" */ input += 2; len = ptr - input; - if (len >= sizeof tmp) + if ((size_t)len >= sizeof tmp) goto expand_variable_out; safe_memcpy (tmp, input, len);