Skip to contentSkip to conversation

move DMI prefix strings into struct mafield[]

PATCH New Helge Deller 1 participant 1 message Nov 21, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 move DMI prefix strings into struct mafield[]

Move the DMI prefix strings (which are max. 3 chars long) directly into the struct mafield[], instead of storing a pointer to them.
This introduces no functional changes, but gives the advantage of saving some bytes in the executable (additional stringspace and the relocation table entries are gone).

drivers/firmware/dmi-id.c +3 -3
@@ -70,7 +70,7 @@ static void ascii_filter(char *d, const char *s)
 static ssize_t get_modalias(char *buffer, size_t buffer_size)
 {
 	static const struct mafield {
-		const char *prefix;
+		char prefix[4];
 		int field;
 	} fields[] = {
 		{ "bvn", DMI_BIOS_VENDOR },
@@ -85,7 +85,7 @@ static ssize_t get_modalias(char *buffer, size_t buffer_size)
 		{ "cvn", DMI_CHASSIS_VENDOR },
 		{ "ct",  DMI_CHASSIS_TYPE },
 		{ "cvr", DMI_CHASSIS_VERSION },
-		{ NULL,  DMI_NONE }
+		{ "",    DMI_NONE }
 	};
 
 	ssize_t l, left;
@@ -95,7 +95,7 @@ static ssize_t get_modalias(char *buffer, size_t buffer_size)
 	strcpy(buffer, "dmi");
 	p = buffer + 3; left = buffer_size - 4;
 
-	for (f = fields; f->prefix && left > 0; f++) {
+	for (f = fields; f->prefix[0] && left > 0; f++) {
 		const char *c;
 		char *t;