-int prepare_cmos_write (const cmos_entry_t *e, const char value_str[],
- unsigned long long *value)
- { const cmos_enum_t *q;
- unsigned long long out;
- const char *p;
- char *memory;
- int negative, result, found_one;
-
- if ((result = prepare_cmos_op_common(e)) != OK)
- return result;
-
- switch (e->config)
- { case CMOS_ENTRY_ENUM:
- /* Make sure the user's input corresponds to a valid option. */
- for (q = first_cmos_enum_id(e->config_id), found_one = 0;
- q != NULL;
- q = next_cmos_enum_id(q))
- { found_one = 1;
-
- if (!strncmp(q->text, value_str, CMOS_MAX_TEXT_LENGTH))
- break;
- }
-
- if (!found_one)
- return CMOS_OP_NO_MATCHING_ENUM;
-
- if (q == NULL)
- return CMOS_OP_BAD_ENUM_VALUE;
-
- out = q->value;
- break;
-
- case CMOS_ENTRY_HEX:
- /* See if the first character of 'value_str' (excluding any initial
- * whitespace) is a minus sign.
- */
- for (p = value_str; isspace(*p); p++);
- negative = (*p == '-');
-
- out = strtoull(value_str, (char **) &p, 0);
-
- if (*p)
- return CMOS_OP_INVALID_INT;
-
- /* If we get this far, the user specified a valid integer. However
- * we do not currently support the use of negative numbers as CMOS
- * parameter values.
- */
- if (negative)
- return CMOS_OP_NEGATIVE_INT;
-
- break;
-
- case CMOS_ENTRY_STRING:
- if (e->length < (8 * strlen(value_str)))
- return CMOS_OP_VALUE_TOO_WIDE;
- memory = malloc(e->length / 8);
- memset(memory, 0, e->length / 8);
- strcpy(memory, value_str);
- out = (unsigned long)memory;
- break;
-
- default:
- BUG();
- }
-
- if ((e->length < (8 * sizeof(*value))) &&
- (out >= (1ull << e->length)))
- return CMOS_OP_VALUE_TOO_WIDE;
-
- *value = out;
- return OK;
- }
+int prepare_cmos_write(const cmos_entry_t * e, const char value_str[],
+ unsigned long long *value)
+{
+ const cmos_enum_t *q;
+ unsigned long long out;
+ const char *p;
+ char *memory;
+ int negative, result, found_one;
+
+ if ((result = prepare_cmos_op_common(e)) != OK)
+ return result;
+
+ switch (e->config) {
+ case CMOS_ENTRY_ENUM:
+ /* Make sure the user's input corresponds to a valid option. */
+ for (q = first_cmos_enum_id(e->config_id), found_one = 0;
+ q != NULL; q = next_cmos_enum_id(q)) {
+ found_one = 1;
+
+ if (!strncmp(q->text, value_str, CMOS_MAX_TEXT_LENGTH))
+ break;
+ }
+
+ if (!found_one)
+ return CMOS_OP_NO_MATCHING_ENUM;
+
+ if (q == NULL)
+ return CMOS_OP_BAD_ENUM_VALUE;
+
+ out = q->value;
+ break;
+
+ case CMOS_ENTRY_HEX:
+ /* See if the first character of 'value_str' (excluding
+ * any initial whitespace) is a minus sign.
+ */
+ for (p = value_str; isspace(*p); p++) ;
+ negative = (*p == '-');
+
+ out = strtoull(value_str, (char **)&p, 0);
+
+ if (*p)
+ return CMOS_OP_INVALID_INT;
+
+ /* If we get this far, the user specified a valid integer.
+ * However we do not currently support the use of negative
+ * numbers as CMOS parameter values.
+ */
+ if (negative)
+ return CMOS_OP_NEGATIVE_INT;
+
+ break;
+
+ case CMOS_ENTRY_STRING:
+ if (e->length < (8 * strlen(value_str)))
+ return CMOS_OP_VALUE_TOO_WIDE;
+ memory = malloc(e->length / 8);
+ memset(memory, 0, e->length / 8);
+ strcpy(memory, value_str);
+ out = (unsigned long)memory;
+ break;
+
+ default:
+ BUG();
+ }
+
+ if ((e->length < (8 * sizeof(*value))) && (out >= (1ull << e->length)))
+ return CMOS_OP_VALUE_TOO_WIDE;
+
+ *value = out;
+ return OK;
+}