replacing if-then-else strcmp ladders with switch cases

jim.cromie at gmail.com jim.cromie at gmail.com
Fri Jun 12 14:05:55 EDT 2020


considering  lib/dynamic_debug.c
we have

...
} else if (!strcmp(words[i], "module")) {
    rc = check_set(&query->module, words[i+1], "module");
} else if (!strcmp(words[i], "format")) {
...

are there any built-in hash functions which would allow this ?

switch (keyword) {
case Hash("module"):
    ..... break;
case Hash("format"):
    .... break;
default: return -EINVAL
}



More information about the Kernelnewbies mailing list