Skip to content

Commit e1352d7

Browse files
committed
modpost: refactor do_vmbus_entry()
Optimize the size of guid_name[], as it only requires 1 additional byte for '\0' instead of 2. Simplify the loop by incrementing the iterator by 1 instead of 2. Remove the unnecessary TO_NATIVE() call, as the guid is represented as a byte stream. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
1 parent bf36b4b commit e1352d7

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

scripts/mod/file2alias.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,15 +812,13 @@ static void do_virtio_entry(struct module *mod, void *symval)
812812
* Each byte of the guid will be represented by two hex characters
813813
* in the name.
814814
*/
815-
816815
static void do_vmbus_entry(struct module *mod, void *symval)
817816
{
818-
int i;
819817
DEF_FIELD_ADDR(symval, hv_vmbus_device_id, guid);
820-
char guid_name[(sizeof(*guid) + 1) * 2];
818+
char guid_name[sizeof(*guid) * 2 + 1];
821819

822-
for (i = 0; i < (sizeof(*guid) * 2); i += 2)
823-
sprintf(&guid_name[i], "%02x", TO_NATIVE((guid->b)[i/2]));
820+
for (int i = 0; i < sizeof(*guid); i++)
821+
sprintf(&guid_name[i * 2], "%02x", guid->b[i]);
824822

825823
module_alias_printf(mod, false, "vmbus:%s", guid_name);
826824
}

0 commit comments

Comments
 (0)