From: jim.cromie@gmail.com
To: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: replacing if-then-else strcmp ladders with switch cases
Date: Fri, 12 Jun 2020 12:05:55 -0600 [thread overview]
Message-ID: <CAJfuBxzHTCxXZhEQ4Chb4Vp-g5M-S+2aPH7m+skit27FRMnbxQ@mail.gmail.com> (raw)
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
}
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
next reply other threads:[~2020-06-12 18:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-12 18:05 jim.cromie [this message]
2020-06-13 5:02 ` replacing if-then-else strcmp ladders with switch cases Valdis Klētnieks
2020-06-13 17:08 ` jim.cromie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJfuBxzHTCxXZhEQ4Chb4Vp-g5M-S+2aPH7m+skit27FRMnbxQ@mail.gmail.com \
--to=jim.cromie@gmail.com \
--cc=kernelnewbies@kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).