devfsd: fix formatting (Tito <farmatito@tiscali.it>)

ash: fix SEGV if type has zero parameters
This commit is contained in:
Denis Vlasenko 2007-06-25 22:55:34 +00:00
parent 80b8b39899
commit 1fc6238ffa
2 changed files with 447 additions and 510 deletions

View File

@ -344,8 +344,7 @@ static void do_ioctl_and_die(int fd, int request, unsigned long event_mask_flag)
static void fork_and_execute(int die, char *arg0, char **arg)
{
switch ( fork () )
{
switch (fork()) {
case 0:
/* Child */
break;
@ -357,16 +356,14 @@ static void fork_and_execute(int die, char *arg0, char **arg )
return;
default:
/* Parent : ok : return or exit */
if(arg0 != NULL)
{
if (arg0 != NULL) {
wait(NULL);
return;
}
exit(EXIT_SUCCESS);
}
/* Child : if arg0 != NULL do execvp */
if(arg0 != NULL )
{
if (arg0 != NULL) {
BB_EXECVP(arg0, arg);
msg_logger_and_die(LOG_ERR, "execvp");
}
@ -394,14 +391,15 @@ static unsigned int scan_dev_name_common(const char *d, unsigned int n, int adde
static unsigned int scan_dev_name(const char *d, unsigned int n, char *ptr)
{
if (d[0] == 's' && d[1] == 'c' && d[2] == 's' && d[3] == 'i' && d[4] == '/') {
if( d[n - 7]=='g' && d[n - 6]=='e' && d[n - 5]=='n' &&
d[n - 4]=='e' && d[n - 3]=='r' && d[n - 2]=='i' &&
d[n - 1]=='c' )
if (d[n - 7] == 'g' && d[n - 6] == 'e' && d[n - 5] == 'n'
&& d[n - 4] == 'e' && d[n - 3] == 'r' && d[n - 2] == 'i' && d[n - 1] == 'c'
)
return 1;
return scan_dev_name_common(d, n, 0, ptr);
}
if(d[0]=='i' && d[1]=='d' && d[2]=='e' && d[3]=='/' &&
d[4]=='h' && d[5]=='o' && d[6]=='s' && d[7]=='t')
if (d[0] == 'i' && d[1] == 'd' && d[2] == 'e' && d[3] == '/'
&& d[4] == 'h' && d[5] == 'o' && d[6] == 's' && d[7] == 't'
)
return scan_dev_name_common(d, n, 4, ptr);
if (d[0] == 's' && d[1] == 'b' && d[2] == 'p' && d[3] == '/')
return 10;
@ -429,10 +427,8 @@ int devfsd_main (int argc, char **argv)
if (argc < 2)
bb_show_usage();
for (count = 2; count < argc; ++count)
{
if(argv[count][0] == '-')
{
for (count = 2; count < argc; ++count) {
if (argv[count][0] == '-') {
if (argv[count][1] == 'v' && !argv[count][2]) /* -v */
print_version = TRUE;
else if (ENABLE_DEVFSD_FG_NP && argv[count][1] == 'f'
@ -498,8 +494,7 @@ int devfsd_main (int argc, char **argv)
if (ENABLE_DEVFSD_FG_NP && no_polling)
exit(0);
if (do_daemon)
{
if (do_daemon) {
/* Release so that the child can grab it */
do_ioctl_and_die(fd, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0);
fork_and_execute(DIE, NULL, NULL);
@ -508,8 +503,7 @@ int devfsd_main (int argc, char **argv)
setpgid(0, 0); /* Become process group leader */
}
while (TRUE)
{
while (TRUE) {
do_scan = do_servicing(fd, event_mask);
free_config();
@ -538,13 +532,11 @@ static void read_config_file (char *path, int optional, unsigned long *event_mas
debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, path);
if (stat (path, &statbuf) == 0 )
{
if (stat(path, &statbuf) == 0) {
/* Don't read 0 length files: ignored */
/*if (statbuf.st_size == 0)
return;*/
if ( S_ISDIR (statbuf.st_mode) )
{
if (S_ISDIR(statbuf.st_mode)) {
/* strip last / from dirname so we don't need to check for it later */
while (path && path[1] != '\0' && path[strlen(path) - 1] == '/')
path[strlen(path) - 1] = '\0';
@ -552,10 +544,8 @@ static void read_config_file (char *path, int optional, unsigned long *event_mas
dir_operation(READ_CONFIG, path, 0, event_mask);
return;
}
if ( ( fp = fopen (path, "r") ) != NULL )
{
while (fgets (buf, STRING_LENGTH, fp) != NULL)
{
if ((fp = fopen(path, "r")) != NULL) {
while (fgets(buf, STRING_LENGTH, fp) != NULL) {
/* Skip whitespace */
for (line = buf; isspace(*line); ++line)
/*VOID*/;
@ -608,8 +598,7 @@ static void process_config_line (const char *line, unsigned long *event_mask)
i = index_in_str_array(options, when);
/*"CLEAR_CONFIG"*/
if( i == 0)
{
if (i == 0) {
free_config();
*event_mask = 0;
return;
@ -619,16 +608,14 @@ static void process_config_line (const char *line, unsigned long *event_mask)
goto process_config_line_err;
/* "INCLUDE" & "OPTIONAL_INCLUDE" */
if( i == 1 || i == 2 )
{
if (i == 1 || i == 2) {
st_expr_expand(name, STRING_LENGTH, name, get_variable, NULL);
msg_logger(LOG_INFO, "%sinclude: %s", (toupper(when[0]) == 'I') ? "": "optional_", name);
read_config_file(name, (toupper(when[0]) == 'I') ? FALSE : TRUE, event_mask);
return;
}
/* "RESTORE" */
if( i == 3)
{
if (i == 3) {
dir_operation(RESTORE,name, strlen(name),NULL);
return;
}
@ -638,28 +625,24 @@ static void process_config_line (const char *line, unsigned long *event_mask)
new = xmalloc(sizeof *new);
memset(new, 0, sizeof *new);
for (count = 0; event_types[count].config_name != NULL; ++count)
{
for (count = 0; event_types[count].config_name != NULL; ++count) {
if (strcasecmp(when, event_types[count].config_name) != 0)
continue;
new->action.when = event_types[count].type;
break;
}
if (event_types[count].config_name == NULL)
{
if (event_types[count].config_name == NULL) {
msg="WHEN in";
goto process_config_line_err;
}
i = index_in_str_array(options, what);
switch (i)
{
switch (i) {
case 4: /* "PERMISSIONS" */
new->action.what = AC_PERMISSIONS;
/* Get user and group */
if ( ( ptr = strchr (p[0], '.') ) == NULL )
{
if ((ptr = strchr(p[0], '.')) == NULL) {
msg="UID.GID";
goto process_config_line_err; /*"missing '.' in UID.GID"*/
}
@ -747,8 +730,7 @@ static int do_servicing (int fd, unsigned long event_mask)
/* Tell devfs what events we care about */
tmp_event_mask = event_mask;
do_ioctl_and_die(fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask);
while (!caught_signal)
{
while (!caught_signal) {
errno = 0;
bytes = read(fd,(char *) &info, sizeof info);
if (caught_signal)
@ -759,8 +741,7 @@ static int do_servicing (int fd, unsigned long event_mask)
break;
service_name(&info);
}
if (caught_signal)
{
if (caught_signal) {
int c_sighup = caught_sighup;
caught_signal = FALSE;
@ -785,26 +766,27 @@ static void service_name (const struct devfsd_notify_struct *info)
debug_msg_logger(LOG_ERR, "lost %u events", info->overrun_count);
/* Discard lookups on "/dev/log" and "/dev/initctl" */
if( info->type == DEVFSD_NOTIFY_LOOKUP &&
((info->devname[0]=='l' && info->devname[1]=='o' &&
info->devname[2]=='g' && !info->devname[3]) ||
( info->devname[0]=='i' && info->devname[1]=='n' &&
info->devname[2]=='i' && info->devname[3]=='t' &&
info->devname[4]=='c' && info->devname[5]=='t' &&
info->devname[6]=='l' && !info->devname[7])))
if (info->type == DEVFSD_NOTIFY_LOOKUP
&& ((info->devname[0] == 'l' && info->devname[1] == 'o'
&& info->devname[2] == 'g' && !info->devname[3])
|| (info->devname[0] == 'i' && info->devname[1] == 'n'
&& info->devname[2] == 'i' && info->devname[3] == 't'
&& info->devname[4] == 'c' && info->devname[5] == 't'
&& info->devname[6] == 'l' && !info->devname[7]))
)
return;
for (entry = first_config; entry != NULL; entry = entry->next)
{
for (entry = first_config; entry != NULL; entry = entry->next) {
/* First check if action matches the type, then check if name matches */
if (info->type != entry->action.when || regexec (&entry->preg, info->devname, MAX_SUBEXPR, mbuf, 0) != 0 )
if (info->type != entry->action.when
|| regexec(&entry->preg, info->devname, MAX_SUBEXPR, mbuf, 0) != 0)
continue;
for (n = 0;(n < MAX_SUBEXPR) && (mbuf[n].rm_so != -1); ++n)
/* VOID */;
debug_msg_logger(LOG_INFO, "%s: action.what %d", __FUNCTION__, entry->action.what);
switch (entry->action.what)
{
switch (entry->action.what) {
case AC_PERMISSIONS:
action_permissions(info, entry);
break;
@ -847,8 +829,7 @@ static void action_permissions (const struct devfsd_notify_struct *info,
if (stat(info->devname, &statbuf) != 0 ||
chmod(info->devname,(statbuf.st_mode & S_IFMT) |(entry->u.permissions.mode & ~S_IFMT)) != 0 ||
chown (info->devname, entry->u.permissions.uid, entry->u.permissions.gid) != 0)
{
chown(info->devname, entry->u.permissions.uid, entry->u.permissions.gid) != 0) {
msg_logger(LOG_ERR, "Can't chmod or chown: %s: %m",info->devname);
}
} /* End Function action_permissions */
@ -897,8 +878,7 @@ static void action_execute (const struct devfsd_notify_struct *info,
gv_info.info = info;
gv_info.devname = info->devname;
snprintf(gv_info.devpath, sizeof(gv_info.devpath), "%s/%s", mount_point, info->devname);
for (count = 0; entry->u.execute.argv[count] != NULL; ++count)
{
for (count = 0; entry->u.execute.argv[count] != NULL; ++count) {
expand_expression(largv[count], STRING_LENGTH,
entry->u.execute.argv[count],
get_variable, &gv_info,
@ -990,8 +970,7 @@ static void action_compat (const struct devfsd_notify_struct *info, unsigned int
};
/* First construct compatibility name */
switch (action)
{
switch (action) {
case AC_MKOLDCOMPAT:
case AC_RMOLDCOMPAT:
compat_name = get_old_name(info->devname, info->namelen, compat_buf, info->major, info->minor);
@ -1022,8 +1001,7 @@ static void action_compat (const struct devfsd_notify_struct *info, unsigned int
sprintf(compat_buf, fmt[i], host, bus, target, lun, atoi(ptr + 4));
/* 5 == scsi/mt */
if( i == 5)
{
if (i == 5) {
rewind_ = info->devname[info->namelen - 1];
if (rewind_ != 'n')
rewind_ = '\0';
@ -1047,8 +1025,7 @@ static void action_compat (const struct devfsd_notify_struct *info, unsigned int
debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, compat_name);
/* Now decide what to do with it */
switch (action)
{
switch (action) {
case AC_MKOLDCOMPAT:
case AC_MKNEWCOMPAT:
mksymlink(dest_name, compat_name);
@ -1102,18 +1079,16 @@ static int copy_inode (const char *destpath, const struct stat *dest_stat,
debug_msg_logger(LOG_INFO, __FUNCTION__);
if ( (source_stat->st_mode & S_IFMT) == (dest_stat->st_mode & S_IFMT) )
{
if ((source_stat->st_mode & S_IFMT) ==(dest_stat->st_mode & S_IFMT)) {
/* Same type */
if ( S_ISLNK (source_stat->st_mode) )
{
if (( source_len = readlink (sourcepath, source_link, STRING_LENGTH - 1) ) < 0 ||
( dest_len = readlink (destpath , dest_link , STRING_LENGTH - 1) ) < 0 )
if (S_ISLNK(source_stat->st_mode)) {
if ((source_len = readlink(sourcepath, source_link, STRING_LENGTH - 1)) < 0
|| (dest_len = readlink(destpath , dest_link , STRING_LENGTH - 1)) < 0
)
return FALSE;
source_link[source_len] = '\0';
dest_link[dest_len] = '\0';
if ( (source_len != dest_len) || (strcmp (source_link, dest_link) != 0) )
{
if ((source_len != dest_len) || (strcmp(source_link, dest_link) != 0)) {
unlink(destpath);
symlink(source_link, destpath);
}
@ -1125,8 +1100,7 @@ static int copy_inode (const char *destpath, const struct stat *dest_stat,
}
/* Different types: unlink and create */
unlink(destpath);
switch (source_stat->st_mode & S_IFMT)
{
switch (source_stat->st_mode & S_IFMT) {
case S_IFSOCK:
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
break;
@ -1178,16 +1152,13 @@ static void free_config (void)
debug_msg_logger(LOG_INFO, __FUNCTION__);
for (c_entry = first_config; c_entry != NULL; c_entry = next)
{
for (c_entry = first_config; c_entry != NULL; c_entry = next) {
unsigned int count;
next = c_entry->next;
regfree(&c_entry->preg);
if (c_entry->action.what == AC_EXECUTE)
{
for (count = 0; count < MAX_ARGS; ++count)
{
if (c_entry->action.what == AC_EXECUTE) {
for (count = 0; count < MAX_ARGS; ++count) {
if (c_entry->u.execute.argv[count] == NULL)
break;
free(c_entry->u.execute.argv[count]);
@ -1252,8 +1223,7 @@ static mode_t get_mode (const char *string)
mode = 0;
i = S_IRUSR;
while (i>0)
{
while (i > 0) {
if (string[0] == 'r' || string[0] == 'w' || string[0] == 'x')
mode += i;
i = i/2;
@ -1295,8 +1265,7 @@ static const char *get_variable (const char *variable, void *info)
if (i > 6 || i < 0 || (i > 1 && gv_info == NULL))
return NULL;
if( i >= 0 && i <= 3)
{
if (i >= 0 && i <= 3) {
debug_msg_logger(LOG_INFO, "%s: i=%d %s", __FUNCTION__, i, field_names[i + 7]);
return field_names[i + 7];
}
@ -1349,27 +1318,23 @@ static void dir_operation(int type, const char * dir_name, int var, unsigned lon
debug_msg_logger(LOG_INFO, __FUNCTION__);
if((dp = opendir( dir_name))==NULL)
{
if ((dp = opendir(dir_name))==NULL) {
debug_msg_logger(LOG_ERR, "opendir: %s: %m", dir_name);
return;
}
while ( (de = readdir (dp) ) != NULL )
{
while ((de = readdir(dp)) != NULL) {
if (de->d_name && DOT_OR_DOTDOT(de->d_name))
continue;
snprintf(path, sizeof(path), "%s/%s", dir_name, de->d_name);
debug_msg_logger(LOG_ERR, "%s: %s", __FUNCTION__, path);
if (lstat (path, &statbuf) != 0)
{
if (lstat(path, &statbuf) != 0) {
debug_msg_logger(LOG_ERR, "%s: %s: %m", __FUNCTION__, path);
continue;
}
switch (type)
{
switch (type) {
case SERVICE:
service(statbuf, path);
break;
@ -1414,8 +1379,7 @@ static int make_dir_tree (const char *path)
{
debug_msg_logger(LOG_INFO, __FUNCTION__);
if (bb_make_directory( dirname((char *)path), -1, FILEUTILS_RECUR )==-1)
{
if (bb_make_directory(dirname((char *)path), -1, FILEUTILS_RECUR) == -1) {
debug_msg_logger(LOG_ERR, "%s: %s: %m",__FUNCTION__, path);
return FALSE;
}
@ -1483,18 +1447,14 @@ static void expand_regexp (char *output, size_t outsize, const char *input,
/* Copy the input string into the output buffer, replacing '\\' with '\'
and '\0' .. '\9' with subexpressions 0 .. 9, if they exist. Other \x
codes are deleted */
while ( (c != '\0') && (outsize != 0) )
{
while ((c != '\0') && (outsize != 0)) {
c = *input;
++input;
if (c == '\\')
{
if (c == '\\') {
c = *input;
++input;
if (c != '\\')
{
if ((c >= '0') && (c <= last_exp))
{
if (c != '\\') {
if ((c >= '0') && (c <= last_exp)) {
const regmatch_t *subexp = ex + (c - '0');
unsigned int sublen = subexp->rm_eo - subexp->rm_so;
@ -1597,12 +1557,10 @@ const char *get_old_name (const char *devname, unsigned int namelen,
debug_msg_logger(LOG_INFO, __FUNCTION__);
for (trans = translate_table; trans->match != NULL; ++trans)
{
for (trans = translate_table; trans->match != NULL; ++trans) {
len = strlen(trans->match);
if (strncmp (devname, trans->match, len) == 0)
{
if (strncmp(devname, trans->match, len) == 0) {
if (trans->format == NULL)
return devname + len;
sprintf(buffer, trans->format, devname + len);
@ -1629,8 +1587,7 @@ const char *get_old_name (const char *devname, unsigned int namelen,
compat_name = write_old_sd_name(buffer, major, minor,((i == 2)?"":(ptr + 4)));
/* 5 == scsi/mt */
if( i == 5)
{
if (i == 5) {
mode = ptr[2];
if (mode == 'n')
mode = '\0';
@ -1648,15 +1605,13 @@ const char *get_old_name (const char *devname, unsigned int namelen,
sprintf(buffer, fmt[i], ptr + 2, minor & 0x7f);
/* 11 == vcc/ */
if( i == 11 )
{
if (i == 11) {
sprintf(buffer, fmt[i], devname + 4);
if (buffer[3] == '0')
buffer[3] = '\0';
}
/* 12 == pty/ */
if( i == 12 )
{
if (i == 12) {
pty1 = "pqrstuvwxyzabcde";
pty2 = "0123456789abcdef";
indexx = atoi(devname + 5);
@ -1684,13 +1639,12 @@ static char get_old_ide_name (unsigned int major, unsigned int minor)
/* I hope it works like the previous code as it saves a few bytes. Tito ;P */
do {
if( i==IDE0_MAJOR || i==IDE1_MAJOR || i==IDE2_MAJOR ||
i==IDE3_MAJOR || i==IDE4_MAJOR || i==IDE5_MAJOR ||
i==IDE6_MAJOR || i==IDE7_MAJOR || i==IDE8_MAJOR ||
i==IDE9_MAJOR )
{
if((unsigned int)i==major)
{
if (i == IDE0_MAJOR || i == IDE1_MAJOR || i == IDE2_MAJOR
|| i == IDE3_MAJOR || i == IDE4_MAJOR || i == IDE5_MAJOR
|| i == IDE6_MAJOR || i == IDE7_MAJOR || i == IDE8_MAJOR
|| i == IDE9_MAJOR
) {
if ((unsigned int)i == major) {
letter = c;
break;
}
@ -1719,13 +1673,11 @@ static char *write_old_sd_name (char *buffer,
debug_msg_logger(LOG_INFO, __FUNCTION__);
if (major == 8)
{
if (major == 8) {
sprintf(buffer, "sd%c%s", 'a' + (minor >> 4), part);
return buffer;
}
if ( (major > 64) && (major < 72) )
{
if ((major > 64) && (major < 72)) {
disc_index = ((major - 64) << 4) +(minor >> 4);
if (disc_index < 26)
sprintf(buffer, "sd%c%s", 'a' + disc_index, part);
@ -1768,10 +1720,8 @@ int st_expr_expand (char *output, unsigned int length, const char *input,
if (length > BUFFER_SIZE)
length = BUFFER_SIZE;
for (; TRUE; ++input)
{
switch (ch = *input)
{
for (; TRUE; ++input) {
switch (ch = *input) {
case '$':
/* Variable expansion */
input = expand_variable(buffer, length, &out_pos, ++input, get_variable_func, info);
@ -1781,11 +1731,9 @@ int st_expr_expand (char *output, unsigned int length, const char *input,
case '~':
/* Home directory expansion */
ch = input[1];
if ( isspace (ch) || (ch == '/') || (ch == '\0') )
{
if (isspace(ch) ||(ch == '/') ||(ch == '\0')) {
/* User's own home directory: leave separator for next time */
if ( ( env = getenv ("HOME") ) == NULL )
{
if ((env = getenv("HOME")) == NULL) {
msg_logger(LOG_INFO, bb_msg_variable_not_found, "HOME");
return FALSE;
}
@ -1804,8 +1752,7 @@ int st_expr_expand (char *output, unsigned int length, const char *input,
goto st_expr_expand_out;
safe_memcpy(tmp, input, len);
input = ptr - 1;
if ( ( pwent = getpwnam (tmp) ) == NULL )
{
if ((pwent = getpwnam(tmp)) == NULL) {
msg_logger(LOG_INFO, "no pwent for: %s", tmp);
return FALSE;
}
@ -1821,8 +1768,7 @@ int st_expr_expand (char *output, unsigned int length, const char *input,
if (out_pos >= length)
goto st_expr_expand_out;
buffer[out_pos++] = ch;
if (ch == '\0')
{
if (ch == '\0') {
memcpy(output, buffer, out_pos);
return TRUE;
}
@ -1866,8 +1812,7 @@ static const char *expand_variable (char *buffer, unsigned int length,
debug_msg_logger(LOG_INFO, __FUNCTION__);
ch = input[0];
if (ch == '$')
{
if (ch == '$') {
/* Special case for "$$": PID */
sprintf(tmp, "%d",(int) getpid());
len = strlen(tmp);
@ -1879,8 +1824,7 @@ static const char *expand_variable (char *buffer, unsigned int length,
return input;
}
/* Ordinary variable expansion, possibly in braces */
if (ch != '{')
{
if (ch != '{') {
/* Simple variable expansion */
for (ptr = input; isalnum(ch) || (ch == '_') || (ch == ':'); ch = *++ptr)
/* VOID */ ;
@ -1890,8 +1834,7 @@ static const char *expand_variable (char *buffer, unsigned int length,
safe_memcpy(tmp, input, len);
input = ptr - 1;
if ( ( env = get_variable_v2 (tmp, func, info) ) == NULL )
{
if ((env = get_variable_v2(tmp, func, info)) == NULL) {
msg_logger(LOG_INFO, bb_msg_variable_not_found, tmp);
return NULL;
}
@ -1907,8 +1850,7 @@ static const char *expand_variable (char *buffer, unsigned int length,
ch = *++input;
for (ptr = input; isalnum(ch) || (ch == '_'); ch = *++ptr)
/* VOID */;
if (ch == '}')
{
if (ch == '}') {
/* Must be simple variable expansion with "${var}" */
len = ptr - input;
if ((size_t)len >= sizeof tmp)
@ -1920,8 +1862,7 @@ static const char *expand_variable (char *buffer, unsigned int length,
return NULL;
return input + len;
}
if (ch != ':' || ptr[1] != '-' )
{
if (ch != ':' || ptr[1] != '-') {
msg_logger(LOG_INFO, "illegal char in var name");
return NULL;
}
@ -1936,10 +1877,8 @@ static const char *expand_variable (char *buffer, unsigned int length,
/* First skip to closing brace, taking note of nested expressions */
ptr += 2;
ch = ptr[0];
for (open_braces = 1; open_braces > 0; ch = *++ptr)
{
switch (ch)
{
for (open_braces = 1; open_braces > 0; ch = *++ptr) {
switch (ch) {
case '{':
++open_braces;
break;
@ -1955,8 +1894,7 @@ static const char *expand_variable (char *buffer, unsigned int length,
}
--ptr;
/* At this point ptr should point to closing brace of "${var:-word}" */
if ( ( env = get_variable_v2 (tmp, func, info) ) != NULL )
{
if ((env = get_variable_v2(tmp, func, info)) != NULL) {
/* Found environment variable, so skip the input to the closing brace
and return the variable */
input = ptr;
@ -2007,8 +1945,7 @@ static const char *get_variable_v2 (const char *variable,
debug_msg_logger(LOG_INFO, __FUNCTION__);
if (func != NULL)
{
if (func != NULL) {
value = (*func)(variable, info);
if (value != NULL)
return value;

View File

@ -6986,7 +6986,7 @@ typecmd(int argc, char **argv)
int verbose = 1;
/* type -p ... ? (we don't bother checking for 'p') */
if (argv[1][0] == '-') {
if (argv[1] && argv[1][0] == '-') {
i++;
verbose = 0;
}