All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Franke <Christian.Franke@t-online.de>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: __FILE__ (Re: [PATCH] framework for building modules externally)
Date: Thu, 06 Nov 2008 22:10:56 +0100	[thread overview]
Message-ID: <49135D60.5080400@t-online.de> (raw)
In-Reply-To: <20081106145252.GA24460@thorin>

[-- Attachment #1: Type: text/plain, Size: 828 bytes --]

Robert Millan wrote:
> On Wed, Nov 05, 2008 at 10:41:20PM +0100, Christian Franke wrote:
>   
>> PS: The current use of __FILE__ may also add extra unexpected size: For 
>> packaging, configure is often run outside of $srcdir with a absolute 
>> path name. This may result in long __FILE__ strings, like
>> /home/maintainer/packaging/grub/tmp/grub-1.96+20081105-1/src/grub-1.96/kern/disk.c
>>     
>
> This has annoyed me for a while.  Do you know a proper fix?
>
>   
There is apparently no option to modify __FILE__ expansion. Therefore, 
the relative file name has to be specified in the module itself.

See attached patch for a possible fix: Each module using grub_dprintf 
(here disk.c) may specify its name in 'this_file'. When all modules are 
changed, the '#define this_file' and all #undefs can be removed.

Christian


[-- Attachment #2: grub2-dprintf-file.patch --]
[-- Type: text/x-patch, Size: 940 bytes --]

diff --git a/include/grub/misc.h b/include/grub/misc.h
index 15c18f5..36e4bcc 100644
--- a/include/grub/misc.h
+++ b/include/grub/misc.h
@@ -27,7 +27,9 @@
 
 #define ALIGN_UP(addr, align) (((grub_uint64_t)addr + align - 1) & ~(align - 1))
 
-#define grub_dprintf(condition, fmt, args...) grub_real_dprintf(__FILE__, __LINE__, condition, fmt, ## args);
+#define grub_dprintf(condition, fmt, args...) grub_real_dprintf(this_file, __LINE__, condition, fmt, ## args);
+#define this_file __FILE__
+
 /* XXX: If grub_memmove is too slow, we must implement grub_memcpy.  */
 #define grub_memcpy(d,s,n)	grub_memmove ((d), (s), (n))
 
diff --git a/kern/disk.c b/kern/disk.c
index ed82506..039c011 100644
--- a/kern/disk.c
+++ b/kern/disk.c
@@ -25,6 +25,9 @@
 #include <grub/time.h>
 #include <grub/file.h>
 
+#undef this_file
+static const char this_file[] = "kern/disk.c";
+
 #define	GRUB_CACHE_TIMEOUT	2
 
 /* The last time the disk was used.  */

  reply	other threads:[~2008-11-06 21:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-01 12:32 [PATCH] framework for building modules externally Robert Millan
2008-11-01 19:02 ` Robert Millan
2008-11-04 18:55   ` Vesa Jääskeläinen
2008-11-04 19:07     ` Robert Millan
2008-11-04 19:13       ` Vesa Jääskeläinen
2008-11-04 19:39         ` Robert Millan
2008-11-05  6:57           ` Christian Franke
2008-11-05  9:42             ` Robert Millan
2008-11-05 21:41               ` Christian Franke
2008-11-06 14:52                 ` __FILE__ (Re: [PATCH] framework for building modules externally) Robert Millan
2008-11-06 21:10                   ` Christian Franke [this message]
2008-11-07 19:02                     ` Robert Millan
2008-11-10 20:39                       ` Christian Franke
2008-11-06 14:54                 ` [PATCH] framework for building modules externally Robert Millan
2008-11-06 20:43                   ` Christian Franke
2008-11-07 19:05                     ` Robert Millan
2008-11-08 11:33                     ` Robert Millan
2008-11-10 20:44                       ` Christian Franke
2009-04-10 23:19               ` phcoder
2009-04-13 13:55                 ` Robert Millan
2008-11-05  9:51   ` Robert Millan
2008-11-08 11:29     ` Robert Millan

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=49135D60.5080400@t-online.de \
    --to=christian.franke@t-online.de \
    --cc=grub-devel@gnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.