From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=32944 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKSA6-0008Ok-3q for qemu-devel@nongnu.org; Fri, 04 Jun 2010 04:21:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKSA1-0003fw-1c for qemu-devel@nongnu.org; Fri, 04 Jun 2010 04:21:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32581) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKSA0-0003fo-QU for qemu-devel@nongnu.org; Fri, 04 Jun 2010 04:21:49 -0400 Message-ID: <4C08B797.7060702@redhat.com> Date: Fri, 04 Jun 2010 10:21:43 +0200 From: Jes Sorensen MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 10/16] Introduce OS specific cmdline argument handling and move SMB arg to os-posix.c References: <1275583692-11678-1-git-send-email-Jes.Sorensen@redhat.com> <1275583692-11678-11-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org On 06/04/10 10:15, Markus Armbruster wrote: > Jes.Sorensen@redhat.com writes: >> + * Parse OS specific command line options. >> + * return 0 if option handled, -1 otherwise >> + */ >> +int os_parse_cmd_args(const QEMUOption *popt, const char *optarg) >> +{ >> + int ret = 0; >> + switch (popt->index) { >> +#ifdef CONFIG_SLIRP >> + case QEMU_OPTION_smb: >> + if (net_slirp_smb(optarg) < 0) >> + exit(1); >> + break; >> +#endif > > Was #ifndef _WIN32 before. Impact? It was moved to os-posix.c which is only built for non _WIN32, so it has the same effect, except it's not full of ugly #ifdef's >> +/* >> + * Duplicate definition from vl.c to avoid messing up the entire build >> + */ >> +enum { >> +#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ >> + opt_enum, >> +#define DEFHEADING(text) >> +#include "qemu-options.h" >> +#undef DEF >> +#undef DEFHEADING >> +#undef GEN_DOCS >> +}; > > I agree with Richard: this is gross. The enum creation is gross by itself. Only way to get around not duplicating it is to create a new header file to hold just that? >> +/* This is needed for vl.c and the OS specific files */ >> +typedef struct QEMUOption { >> + const char *name; >> + int flags; >> + int index; >> + uint32_t arch_mask; >> +} QEMUOption; >> + > > Ugh. What do you mean? The real ugh! here is that it was created as a typedef. I can change the function to pass in just the index, but I don't know if we will have cases where the rest is needed. > Is this minor improvement of vl.c really worth the headaches elsewhere? vl.c as it is today is gross and un-maintainable. This patch gets rid of a lot of the ugly #ifdefs and makes the code easier to read and maintain. Jes