Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KTab9-0002Ht-QH for mharc-grub-devel@gnu.org; Thu, 14 Aug 2008 07:02:31 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KTab6-0002GO-C1 for grub-devel@gnu.org; Thu, 14 Aug 2008 07:02:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KTab5-0002Fr-9Y for grub-devel@gnu.org; Thu, 14 Aug 2008 07:02:27 -0400 Received: from [199.232.76.173] (port=36924 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KTab5-0002Fj-0r for grub-devel@gnu.org; Thu, 14 Aug 2008 07:02:27 -0400 Received: from moutng.kundenserver.de ([212.227.126.188]:50406) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KTab3-0003bM-WB for grub-devel@gnu.org; Thu, 14 Aug 2008 07:02:26 -0400 Received: from [85.180.28.246] (e180028246.adsl.alicedsl.de [85.180.28.246]) by mrelayeu.kundenserver.de (node=mrelayeu8) with ESMTP (Nemesis) id 0ML31I-1KTab303dy-0006dZ; Thu, 14 Aug 2008 13:02:25 +0200 From: Felix Zielcke To: The development of GRUB 2 In-Reply-To: <87vdy4yspn.fsf@xs4all.nl> References: <1218558487.19045.8.camel@fz.local> <1218558734.19045.10.camel@fz.local> <87fxp9di59.fsf@xs4all.nl> <20080812224041.GB3141@thorin> <1218606980.4008.9.camel@fz.local> <87abfhb60p.fsf@xs4all.nl> <1218659496.25595.7.camel@fz.local> <20080813215023.GA23069@thorin> <1218667156.4010.5.camel@fz.local> <1218670230.4010.11.camel@fz.local> <87vdy4yspn.fsf@xs4all.nl> Content-Type: multipart/mixed; boundary="=-nxQ2Uu+q5biru9oS4L23" Date: Thu, 14 Aug 2008 13:02:30 +0200 Message-Id: <1218711750.5154.11.camel@fz.local> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 X-Provags-ID: V01U2FsdGVkX19a8cqrIxduirI+QsG5EsHfAuggjzhtfCPakAt lNXC3PhqP1L5q45NJ4kn29jMRuHoYYMwaA3NhC03Hxj3qk0ykD glt73xy2dgxRYVSmKjM1DQVewYwng8N X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) Subject: Re: [PATCH] kern/err.c + disk/raid.c error handling fixes X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Aug 2008 11:02:28 -0000 --=-nxQ2Uu+q5biru9oS4L23 Content-Type: text/plain Content-Transfer-Encoding: 7bit Am Donnerstag, den 14.08.2008, 09:13 +0200 schrieb Marco Gerards: > So this patch isn't really required, but you want it for Lenny? 1218558734.19045.10.camel@fz.local That's the one Robert and me thought could be something for lenny. I have forgotten to merge the disk/raid.c changes which Robert wanted to have in the last grub_print_error () patches. As I already told you on IRC, I now start to believe like Robert that the idea isn't that bad to have a function for the utils which prints to stderr but it doestn't `exit ()' liek grub_util_error does. Maybe not only raid.mod has a use for this but others too. > > 2008-08-14 Felix Zielcke > > > > * include/grub/err.h (grub_error_stack_assert): New variable > > declaration. > > * kern/err.c (grub_error_stack_assert): Remove static. > > (grub_print_error): Disable it for [GRUB_UTIL] because ... > > * util/err.c: New file with grub_print_error () using fprintf > > (stderr, ...). > > Can you just use misc.c? As already said on IRC 1218659496.25595.7.camel@fz.local grub-mkimage would then need to have kern/err.c included. > > > * conf/common.rmk: Add it for grub-probe. > > > I have been thinking of an alternative way to fix this. A bit of a > compromise between what you want and what I want and perhaps cleaner. This whole problem, confuses me now myself. Bean is rewriting the whole RAID code anyway and Robert and me would like to have a simple and small patch for lenny. For upstream (i.e. you ;)) I want a clean solution, that's why I did now the RFC topic. Maybe it's just better if I don't think now for lenny. > You could define a function grub_err_printf or something like that. > Which you use in grub_print_error. You can redefine it for > GRUB_UTIL to grub_util_error and to grub_print otherwise. > > I didn't study the code. Will this be easier and cleaner? Thanks to Robert for the hint with the copyright years. As always with me, changelog and code is probable still not perfect ;) but I think the genereal idea behind it is a step to come nearer to a clean good solution for this whole problem (1218699584.4065.26.camel@fz.local) It does compile cleanly i.e. doestn't introduce any warnings at all and it works with the 2 raid/disk.c changes from msgid I said at the beginning of this mail. 2008-08-14 Felix Zielcke * include/grub.err.h (grub_err_printf): New function prototype. * util/misc.c (grub_err_printf): New function. * kern/misc.c [! GRUB_UTIL] (grub_err_printf): New alias for grub_printf. * kern/err.c (grub_print_error): Use grub_err_printf. --=-nxQ2Uu+q5biru9oS4L23 Content-Disposition: attachment; filename=util_err_2.diff Content-Type: text/x-patch; name=util_err_2.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: kern/err.c =================================================================== --- kern/err.c (Revision 1804) +++ kern/err.c (Arbeitskopie) @@ -1,7 +1,7 @@ /* err.c - error handling routines */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2005,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -121,14 +121,14 @@ grub_print_error (void) do { if (grub_errno != GRUB_ERR_NONE) - grub_printf ("error: %s\n", grub_errmsg); + grub_err_printf ("error: %s\n", grub_errmsg); } while (grub_error_pop ()); /* If there was an assert while using error stack, report about it. */ if (grub_error_stack_assert) { - grub_printf ("assert: error stack overflow detected!\n"); + grub_err_printf ("assert: error stack overflow detected!\n"); grub_error_stack_assert = 0; } } Index: kern/misc.c =================================================================== --- kern/misc.c (Revision 1804) +++ kern/misc.c (Arbeitskopie) @@ -133,6 +133,10 @@ grub_printf (const char *fmt, ...) return ret; } +#ifndef GRUB_UTIL +int grub_err_printf (const char *fmt, ...) +__attribute__ ((alias("grub_printf"))); +#endif void grub_real_dprintf (const char *file, const int line, const char *condition, Index: include/grub/err.h =================================================================== --- include/grub/err.h (Revision 1804) +++ include/grub/err.h (Arbeitskopie) @@ -1,7 +1,7 @@ /* err.h - error numbers and prototypes */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2005,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2005,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -64,5 +64,6 @@ void EXPORT_FUNC(grub_fatal) (const char void EXPORT_FUNC(grub_error_push) (void); int EXPORT_FUNC(grub_error_pop) (void); void EXPORT_FUNC(grub_print_error) (void); +int EXPORT_FUNC(grub_err_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); #endif /* ! GRUB_ERR_HEADER */ Index: util/misc.c =================================================================== --- util/misc.c (Revision 1804) +++ util/misc.c (Arbeitskopie) @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2005,2006,2007 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2005,2006,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -74,6 +74,18 @@ grub_util_error (const char *fmt, ...) exit (1); } +int +grub_err_printf (const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start (ap, fmt); + ret = vfprintf (stderr, fmt, ap); + va_end (ap); + + return ret; +} void * xmalloc (size_t size) { --=-nxQ2Uu+q5biru9oS4L23--