summaryrefslogtreecommitdiffstats
path: root/dmi.c
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2010-03-13 17:28:29 +0000
committerUwe Hermann <uwe@hermann-uwe.de>2010-03-13 17:28:29 +0000
commit439597032eae0f41745d9173805945c5c85475eb (patch)
tree76c0a1816f51012775006aa8c82bdfe78901b5ab /dmi.c
parent645c6df21a9570da7f8ac07fe740a0df3a1d4d1c (diff)
downloadast2050-flashrom-439597032eae0f41745d9173805945c5c85475eb.zip
ast2050-flashrom-439597032eae0f41745d9173805945c5c85475eb.tar.gz
Various coding style and cosmetic changes
- Fix coding-style, whitespace, and indentation in a few places. - Consistently use the same spelling ("Super I/O") everywhere. Corresponding to flashrom svn r933. - Make some flashrom stdout output look a bit nicer. Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Diffstat (limited to 'dmi.c')
-rw-r--r--dmi.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/dmi.c b/dmi.c
index 30a4670..bb285f4 100644
--- a/dmi.c
+++ b/dmi.c
@@ -31,18 +31,20 @@ enum dmi_strings {
DMI_BB_MANUFACTURER,
DMI_BB_PRODUCT,
DMI_BB_VERSION,
- DMI_ID_INVALID /* This must always be the last entry */
+ DMI_ID_INVALID, /* This must always be the last entry! */
};
-/* The short_id for baseboard starts with "m" as in mainboard to leave
- "b" available for BIOS */
+/*
+ * The short_id for baseboard starts with "m" as in mainboard to leave
+ * "b" available for BIOS.
+ */
const char *dmidecode_names[DMI_ID_INVALID] = {
"system-manufacturer",
"system-product-name",
"system-version",
"baseboard-manufacturer",
"baseboard-product-name",
- "baseboard-version"
+ "baseboard-version",
};
#define DMI_COMMAND_LEN_MAX 260
@@ -51,7 +53,7 @@ const char *dmidecode_command = "dmidecode";
int has_dmi_support = 0;
char *dmistrings[DMI_ID_INVALID];
-/* strings longer than 4096 in DMI are just insane */
+/* Strings longer than 4096 in DMI are just insane. */
#define DMI_MAX_ANSWER_LEN 4096
static char *get_dmi_string(const char *string_name)
@@ -59,7 +61,8 @@ static char *get_dmi_string(const char *string_name)
FILE *dmidecode_pipe;
char *result;
char answerbuf[DMI_MAX_ANSWER_LEN];
- char commandline[DMI_COMMAND_LEN_MAX+40];
+ char commandline[DMI_COMMAND_LEN_MAX + 40];
+
snprintf(commandline, sizeof(commandline),
"%s -s %s", dmidecode_command, string_name);
dmidecode_pipe = popen(commandline, "r");
@@ -82,7 +85,7 @@ static char *get_dmi_string(const char *string_name)
return NULL;
}
- /* chomp trailing newline */
+ /* Chomp trailing newline. */
if (answerbuf[0] != 0 &&
answerbuf[strlen(answerbuf) - 1] == '\n')
answerbuf[strlen(answerbuf) - 1] = 0;
@@ -99,6 +102,7 @@ void dmi_init(void)
{
int i;
char *chassis_type;
+
has_dmi_support = 1;
for (i = 0; i < DMI_ID_INVALID; i++) {
dmistrings[i] = get_dmi_string(dmidecode_names[i]);
@@ -131,8 +135,9 @@ static int dmi_compare(const char *value, const char *pattern)
{
int anchored = 0;
int patternlen;
+
printf_debug("matching %s against %s\n", value, pattern);
- /* The empty string is part of all strings */
+ /* The empty string is part of all strings! */
if (pattern[0] == 0)
return 1;
@@ -145,11 +150,11 @@ static int dmi_compare(const char *value, const char *pattern)
if (pattern[patternlen - 1] == '$') {
int valuelen = strlen(value);
patternlen--;
- if(patternlen > valuelen)
+ if (patternlen > valuelen)
return 0;
/* full string match: require same length */
- if(anchored && (valuelen != patternlen))
+ if (anchored && (valuelen != patternlen))
return 0;
/* start character to make ends match */
@@ -166,11 +171,12 @@ static int dmi_compare(const char *value, const char *pattern)
int dmi_match(const char *pattern)
{
int i;
+
if (!has_dmi_support)
return 0;
- for (i = 0;i < DMI_ID_INVALID; i++)
- if(dmi_compare(dmistrings[i], pattern))
+ for (i = 0; i < DMI_ID_INVALID; i++)
+ if (dmi_compare(dmistrings[i], pattern))
return 1;
return 0;
OpenPOWER on IntegriCloud