From: Michael Snyder <msnyder@vmware.com>
To: Hui Zhu <teawater@gmail.com>
Cc: gdb-patches ml <gdb-patches@sourceware.org>, mark.kettenis@xs4all.nl
Subject: Re: [RFA/RFC Prec] Add Linux AMD64 process record support second version, (AMD64 Linux system call support) 3/3
Date: Sat, 18 Jul 2009 03:08:00 -0000 [thread overview]
Message-ID: <4A6121FC.3030205@vmware.com> (raw)
In-Reply-To: <daef60380907170149l3e673abv5060dd2f88195127@mail.gmail.com>
Hui Zhu wrote:
> + /* Convert tmpulongest to number in record_linux_system_call. */
> + switch (tmpulongest)
> + {
> + /* sys_read */
> + case 0:
> + num = 3;
> + break;
> + /* sys_write */
> + case 1:
> + num = 4;
> + break;
Hey Hui,
This switch statement is over 1000 lines long! ;-)
It's OK, there's no real rule against that, but it just
makes me think about whether shortening it might make it
any easier to read and maintain...
I thought of suggesting a look-up table, but that would
actually make it harder to read and maintain, I think...
What about this? If you wrote it this way...
case 1: /* sys_write */
you'd save over 250 lines, and I think it would be more readable.
And then, if you abstracted the switch statement out
into a separate function, you could code it like this...
case 1: /* sys_write */
return 4;
case 2: /* sys_open */
and save another 250 lines, cutting the whole thing by half.
You'd have to special-case number 158, of course.
I leave it up to you, you can decide.
Other than that it looks fine. Mark?
next prev parent reply other threads:[~2009-07-18 1:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-07 2:40 Hui Zhu
2009-07-13 3:32 ` Michael Snyder
2009-07-17 12:45 ` Hui Zhu
2009-07-18 3:08 ` Michael Snyder [this message]
2009-07-19 17:19 ` Hui Zhu
2009-07-20 0:57 ` Michael Snyder
2009-07-19 21:03 ` Hui Zhu
2009-07-20 2:31 ` Michael Snyder
2009-07-20 14:13 ` Hui Zhu
2009-07-25 21:05 ` Michael Snyder
2009-07-26 1:14 ` Michael Snyder
2009-07-28 11:22 ` Hui Zhu
2009-08-03 5:41 ` Hui Zhu
2009-08-09 22:58 ` Michael Snyder
2009-08-10 3:15 ` Hui Zhu
2009-08-13 5:43 ` Michael Snyder
2009-07-14 22:19 ` Michael Snyder
2009-07-15 16:52 ` Hui Zhu
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=4A6121FC.3030205@vmware.com \
--to=msnyder@vmware.com \
--cc=gdb-patches@sourceware.org \
--cc=mark.kettenis@xs4all.nl \
--cc=teawater@gmail.com \
/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