From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13251 invoked by alias); 18 Jul 2009 01:20:06 -0000 Received: (qmail 13240 invoked by uid 22791); 18 Jul 2009 01:20:06 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp-outbound-1.vmware.com (HELO smtp-outbound-1.vmware.com) (65.115.85.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 18 Jul 2009 01:20:00 +0000 Received: from jupiter.vmware.com (mailhost5.vmware.com [10.16.68.131]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 0BE834F037; Fri, 17 Jul 2009 18:19:57 -0700 (PDT) Received: from [10.20.94.141] (msnyder-server.eng.vmware.com [10.20.94.141]) by jupiter.vmware.com (Postfix) with ESMTP id 019B0DC478; Fri, 17 Jul 2009 18:19:57 -0700 (PDT) Message-ID: <4A6121FC.3030205@vmware.com> Date: Sat, 18 Jul 2009 03:08:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20080411) MIME-Version: 1.0 To: Hui Zhu CC: gdb-patches ml , mark.kettenis@xs4all.nl Subject: Re: [RFA/RFC Prec] Add Linux AMD64 process record support second version, (AMD64 Linux system call support) 3/3 References: <4A5A8438.6030005@vmware.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-07/txt/msg00443.txt.bz2 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?