On Fri, 12 Jun 2020 12:05:55 -0600, jim.cromie@xxxxxxxxx said: > 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 > } There's hash functions. But they're all cryptographic hashes that return things that are far too many bits to use as the index of a switch. Also, you have the problem that the cases of a switch have to be something that can be evaluated at compile time....
Attachment:
pgpdFRZNJ3idq.pgp
Description: PGP signature
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies