summaryrefslogtreecommitdiff
path: root/dmiopt.c
diff options
context:
space:
mode:
authorkhali <khali>2008-10-26 12:50:21 +0000
committerkhali <khali>2008-10-26 12:50:21 +0000
commitae6a924ba494a37307d9e3a7fa6ee996e0a693ae (patch)
tree980acb3a19879f4489b4d76d1145f4aead0d8dd5 /dmiopt.c
parent90fabb142d5d1eb3ff548997161f226f5ca6bb03 (diff)
downloaddmidecode-ae6a924ba494a37307d9e3a7fa6ee996e0a693ae.tar.gz
Mass coding-style change: add spaces around operators.
Diffstat (limited to 'dmiopt.c')
-rw-r--r--dmiopt.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/dmiopt.c b/dmiopt.c
index 4b35666..a01e5da 100644
--- a/dmiopt.c
+++ b/dmiopt.c
@@ -45,17 +45,17 @@ struct type_keyword
const u8 *type;
};
-static const u8 opt_type_bios[]={ 0, 13, 255 };
-static const u8 opt_type_system[]={ 1, 12, 15, 23, 32, 255 };
-static const u8 opt_type_baseboard[]={ 2, 10, 255 };
-static const u8 opt_type_chassis[]={ 3, 255 };
-static const u8 opt_type_processor[]={ 4, 255 };
-static const u8 opt_type_memory[]={ 5, 6, 16, 17, 255 };
-static const u8 opt_type_cache[]={ 7, 255 };
-static const u8 opt_type_connector[]={ 8, 255 };
-static const u8 opt_type_slot[]={ 9, 255 };
-
-static const struct type_keyword opt_type_keyword[]={
+static const u8 opt_type_bios[] = { 0, 13, 255 };
+static const u8 opt_type_system[] = { 1, 12, 15, 23, 32, 255 };
+static const u8 opt_type_baseboard[] = { 2, 10, 255 };
+static const u8 opt_type_chassis[] = { 3, 255 };
+static const u8 opt_type_processor[] = { 4, 255 };
+static const u8 opt_type_memory[] = { 5, 6, 16, 17, 255 };
+static const u8 opt_type_cache[] = { 7, 255 };
+static const u8 opt_type_connector[] = { 8, 255 };
+static const u8 opt_type_slot[] = { 9, 255 };
+
+static const struct type_keyword opt_type_keyword[] = {
{ "bios", opt_type_bios },
{ "system", opt_type_system },
{ "baseboard", opt_type_baseboard },
@@ -72,7 +72,7 @@ static void print_opt_type_list(void)
unsigned int i;
fprintf(stderr, "Valid type keywords are:\n");
- for(i=0; i<ARRAY_SIZE(opt_type_keyword); i++)
+ for (i = 0; i < ARRAY_SIZE(opt_type_keyword); i++)
{
fprintf(stderr, " %s\n", opt_type_keyword[i].keyword);
}
@@ -83,10 +83,10 @@ static u8 *parse_opt_type(u8 *p, const char *arg)
unsigned int i;
/* Allocate memory on first call only */
- if(p==NULL)
+ if (p == NULL)
{
- p=(u8 *)calloc(256, sizeof(u8));
- if(p==NULL)
+ p = (u8 *)calloc(256, sizeof(u8));
+ if (p == NULL)
{
perror("calloc");
return NULL;
@@ -94,39 +94,39 @@ static u8 *parse_opt_type(u8 *p, const char *arg)
}
/* First try as a keyword */
- for(i=0; i<ARRAY_SIZE(opt_type_keyword); i++)
+ for (i = 0; i < ARRAY_SIZE(opt_type_keyword); i++)
{
- if(!strcasecmp(arg, opt_type_keyword[i].keyword))
+ if (!strcasecmp(arg, opt_type_keyword[i].keyword))
{
- int j=0;
- while(opt_type_keyword[i].type[j]!=255)
- p[opt_type_keyword[i].type[j++]]=1;
+ int j = 0;
+ while (opt_type_keyword[i].type[j] != 255)
+ p[opt_type_keyword[i].type[j++]] = 1;
goto found;
}
}
/* Else try as a number */
- while(*arg!='\0')
+ while (*arg != '\0')
{
unsigned long val;
char *next;
- val=strtoul(arg, &next, 0);
- if(next==arg)
+ val = strtoul(arg, &next, 0);
+ if (next == arg)
{
fprintf(stderr, "Invalid type keyword: %s\n", arg);
print_opt_type_list();
goto exit_free;
}
- if(val>0xff)
+ if (val > 0xff)
{
fprintf(stderr, "Invalid type number: %lu\n", val);
goto exit_free;
}
- p[val]=1;
- arg=next;
- while(*arg==',' || *arg==' ')
+ p[val] = 1;
+ arg = next;
+ while (*arg == ',' || *arg == ' ')
arg++;
}
@@ -146,7 +146,7 @@ exit_free:
/* This lookup table could admittedly be reworked for improved performance.
Due to the low count of items in there at the moment, it did not seem
worth the additional code complexity though. */
-static const struct string_keyword opt_string_keyword[]={
+static const struct string_keyword opt_string_keyword[] = {
{ "bios-vendor", 0, 0x04, NULL, NULL },
{ "bios-version", 0, 0x05, NULL, NULL },
{ "bios-release-date", 0, 0x08, NULL, NULL },
@@ -176,7 +176,7 @@ static void print_opt_string_list(void)
unsigned int i;
fprintf(stderr, "Valid string keywords are:\n");
- for(i=0; i<ARRAY_SIZE(opt_string_keyword); i++)
+ for (i = 0; i<ARRAY_SIZE(opt_string_keyword); i++)
{
fprintf(stderr, " %s\n", opt_string_keyword[i].keyword);
}
@@ -186,17 +186,17 @@ static int parse_opt_string(const char *arg)
{
unsigned int i;
- if(opt.string)
+ if (opt.string)
{
fprintf(stderr, "Only one string can be specified\n");
return -1;
}
- for(i=0; i<ARRAY_SIZE(opt_string_keyword); i++)
+ for (i = 0; i < ARRAY_SIZE(opt_string_keyword); i++)
{
- if(!strcasecmp(arg, opt_string_keyword[i].keyword))
+ if (!strcasecmp(arg, opt_string_keyword[i].keyword))
{
- opt.string=&opt_string_keyword[i];
+ opt.string = &opt_string_keyword[i];
return 0;
}
}
@@ -216,7 +216,7 @@ int parse_command_line(int argc, char * const argv[])
{
int option;
const char *optstring = "d:hqs:t:uV";
- struct option longopts[]={
+ struct option longopts[] = {
{ "dev-mem", required_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
{ "quiet", no_argument, NULL, 'q' },
@@ -229,44 +229,44 @@ int parse_command_line(int argc, char * const argv[])
{ 0, 0, 0, 0 }
};
- while((option=getopt_long(argc, argv, optstring, longopts, NULL))!=-1)
- switch(option)
+ while ((option = getopt_long(argc, argv, optstring, longopts, NULL)) != -1)
+ switch (option)
{
case 'B':
- opt.flags|=FLAG_DUMP_BIN;
- opt.dumpfile=optarg;
+ opt.flags |= FLAG_DUMP_BIN;
+ opt.dumpfile = optarg;
break;
case 'F':
- opt.flags|=FLAG_FROM_DUMP;
- opt.dumpfile=optarg;
+ opt.flags |= FLAG_FROM_DUMP;
+ opt.dumpfile = optarg;
break;
case 'd':
- opt.devmem=optarg;
+ opt.devmem = optarg;
break;
case 'h':
- opt.flags|=FLAG_HELP;
+ opt.flags |= FLAG_HELP;
break;
case 'q':
- opt.flags|=FLAG_QUIET;
+ opt.flags |= FLAG_QUIET;
break;
case 's':
- if(parse_opt_string(optarg)<0)
+ if (parse_opt_string(optarg) < 0)
return -1;
- opt.flags|=FLAG_QUIET;
+ opt.flags |= FLAG_QUIET;
break;
case 't':
- opt.type=parse_opt_type(opt.type, optarg);
- if(opt.type==NULL)
+ opt.type = parse_opt_type(opt.type, optarg);
+ if (opt.type == NULL)
return -1;
break;
case 'u':
- opt.flags|=FLAG_DUMP;
+ opt.flags |= FLAG_DUMP;
break;
case 'V':
- opt.flags|=FLAG_VERSION;
+ opt.flags |= FLAG_VERSION;
break;
case '?':
- switch(optopt)
+ switch (optopt)
{
case 's':
fprintf(stderr, "String keyword expected\n");
@@ -281,16 +281,16 @@ int parse_command_line(int argc, char * const argv[])
}
/* Check for mutually exclusive output format options */
- if((opt.string!=NULL)+(opt.type!=NULL)
- +!!(opt.flags & FLAG_DUMP)+!!(opt.flags & FLAG_DUMP_BIN)>1)
+ if ((opt.string != NULL) + (opt.type != NULL)
+ + !!(opt.flags & FLAG_DUMP) + !!(opt.flags & FLAG_DUMP_BIN) > 1)
{
fprintf(stderr, "Options --string, --type, --dump and --dump-bin are mutually exclusive\n");
return -1;
}
- if(opt.flags & (FLAG_DUMP | FLAG_DUMP_BIN))
- opt.flags&=~FLAG_QUIET;
+ if (opt.flags & (FLAG_DUMP | FLAG_DUMP_BIN))
+ opt.flags &= ~FLAG_QUIET;
- if((opt.flags & FLAG_FROM_DUMP) && (opt.flags & FLAG_DUMP_BIN))
+ if ((opt.flags & FLAG_FROM_DUMP) && (opt.flags & FLAG_DUMP_BIN))
{
fprintf(stderr, "Options --from-dump and --dump-bin are mutually exclusive\n");
return -1;
@@ -301,7 +301,7 @@ int parse_command_line(int argc, char * const argv[])
void print_help(void)
{
- static const char *help=
+ static const char *help =
"Usage: dmidecode [OPTIONS]\n"
"Options are:\n"
" -d, --dev-mem FILE Read memory from device FILE (default: " DEFAULT_MEM_DEV ")\n"