* [RFC] Is it okay to just use GNU extensions or should an alternative be provided too?
@ 2008-08-16 12:05 Felix Zielcke
2008-08-16 12:32 ` Vesa Jääskeläinen
2008-08-16 12:39 ` Robert Millan
0 siblings, 2 replies; 8+ messages in thread
From: Felix Zielcke @ 2008-08-16 12:05 UTC (permalink / raw)
To: The development of GRUB 2
I just talked with Marco on IRC.
I have just used asprintf in one of my patches, but now I discovered:
http://grub.enbug.org/BuildingOnNonGnu
So I became a bit unsure now if it's okay to just use asprintf.
Is it okay to just use and don't care about enviroments which don't
use/have glibc?
Or should such GNU extentions just not be used if they can be avoided?
I doubt it would be good to use many `#ifdef _GNU_SOURCE' in the code.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] Is it okay to just use GNU extensions or should an alternative be provided too?
2008-08-16 12:05 [RFC] Is it okay to just use GNU extensions or should an alternative be provided too? Felix Zielcke
@ 2008-08-16 12:32 ` Vesa Jääskeläinen
2008-08-16 12:39 ` Robert Millan
2008-08-16 12:43 ` Felix Zielcke
2008-08-16 12:39 ` Robert Millan
1 sibling, 2 replies; 8+ messages in thread
From: Vesa Jääskeläinen @ 2008-08-16 12:32 UTC (permalink / raw)
To: The development of GRUB 2
Felix Zielcke wrote:
> I just talked with Marco on IRC.
>
> I have just used asprintf in one of my patches, but now I discovered:
> http://grub.enbug.org/BuildingOnNonGnu
>
> So I became a bit unsure now if it's okay to just use asprintf.
>
> Is it okay to just use and don't care about enviroments which don't
> use/have glibc?
>
> Or should such GNU extentions just not be used if they can be avoided?
>
> I doubt it would be good to use many `#ifdef _GNU_SOURCE' in the code.
Please use what ever we have on grub source code already. Then it work
fine also in standalone grub.
It should be possible to use existing functions. I see asprintf just a
wrapper to malloc/sprintf for which there are already versions present
on grub.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] Is it okay to just use GNU extensions or should an alternative be provided too?
2008-08-16 12:05 [RFC] Is it okay to just use GNU extensions or should an alternative be provided too? Felix Zielcke
2008-08-16 12:32 ` Vesa Jääskeläinen
@ 2008-08-16 12:39 ` Robert Millan
2008-08-16 12:48 ` Felix Zielcke
1 sibling, 1 reply; 8+ messages in thread
From: Robert Millan @ 2008-08-16 12:39 UTC (permalink / raw)
To: The development of GRUB 2
On Sat, Aug 16, 2008 at 02:05:25PM +0200, Felix Zielcke wrote:
> I just talked with Marco on IRC.
>
> I have just used asprintf in one of my patches, but now I discovered:
> http://grub.enbug.org/BuildingOnNonGnu
>
> So I became a bit unsure now if it's okay to just use asprintf.
IIRC, asprintf is widely available. At least it's present on *BSD.
> I doubt it would be good to use many `#ifdef _GNU_SOURCE' in the code.
_GNU_SOURCE is used to tell Glibc to enable GNU extensions. When you want
to check from Glibc whether you're on Glibc, __GLIBC__ indicates that.
But using autoconf checks is better anyway.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] Is it okay to just use GNU extensions or should an alternative be provided too?
2008-08-16 12:32 ` Vesa Jääskeläinen
@ 2008-08-16 12:39 ` Robert Millan
2008-08-16 12:43 ` Felix Zielcke
1 sibling, 0 replies; 8+ messages in thread
From: Robert Millan @ 2008-08-16 12:39 UTC (permalink / raw)
To: The development of GRUB 2
On Sat, Aug 16, 2008 at 03:32:28PM +0300, Vesa Jääskeläinen wrote:
>
> Please use what ever we have on grub source code already. Then it work
> fine also in standalone grub.
I think he was referring to util/ code.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] Is it okay to just use GNU extensions or should an alternative be provided too?
2008-08-16 12:32 ` Vesa Jääskeläinen
2008-08-16 12:39 ` Robert Millan
@ 2008-08-16 12:43 ` Felix Zielcke
2008-08-16 12:54 ` Vesa Jääskeläinen
2008-08-16 12:58 ` Robert Millan
1 sibling, 2 replies; 8+ messages in thread
From: Felix Zielcke @ 2008-08-16 12:43 UTC (permalink / raw)
To: The development of GRUB 2
Am Samstag, den 16.08.2008, 15:32 +0300 schrieb Vesa Jääskeläinen:
>
> Please use what ever we have on grub source code already. Then it work
> fine also in standalone grub.
Maybe this time my mail was a bit too short? :)
especially, I ask for asprintf in util/misc.c so just GRUB_UTIL.
But Marco and I thought it would be good to make a general discussion
about GNU extentions.
GCC is needed anyway because of the nested function but what about glibc
or other stuff?
> It should be possible to use existing functions. I see asprintf just a
> wrapper to malloc/sprintf for which there are already versions present
> on grub.
fz@fz:~/grub/grub2.svn$ grep -r asprintf *
util/grub-probe.c: asprintf (&grub_path, "(%s)%s", drive_name, path);
I just discovered that asprintf is indeed already used in the source :)
But yeah maybe there's even in the kernel a use for asprintf,
so maybe a good idea to make a grub_asprintf?
This could be then either always used even if the util/*.c use the
library functions normally or it could be done as with my
grub_print_error change :)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] Is it okay to just use GNU extensions or should an alternative be provided too?
2008-08-16 12:39 ` Robert Millan
@ 2008-08-16 12:48 ` Felix Zielcke
0 siblings, 0 replies; 8+ messages in thread
From: Felix Zielcke @ 2008-08-16 12:48 UTC (permalink / raw)
To: The development of GRUB 2
Am Samstag, den 16.08.2008, 14:39 +0200 schrieb Robert Millan:
> On Sat, Aug 16, 2008 at 02:05:25PM +0200, Felix Zielcke wrote:
> > I just talked with Marco on IRC.
> >
> > I have just used asprintf in one of my patches, but now I discovered:
> > http://grub.enbug.org/BuildingOnNonGnu
> >
> > So I became a bit unsure now if it's okay to just use asprintf.
>
> IIRC, asprintf is widely available. At least it's present on *BSD.
Good.
> > I doubt it would be good to use many `#ifdef _GNU_SOURCE' in the code.
>
> _GNU_SOURCE is used to tell Glibc to enable GNU extensions. When you want
> to check from Glibc whether you're on Glibc, __GLIBC__ indicates that.
>
> But using autoconf checks is better anyway.
configure.ac has already AC_GNU_SOURCE
config.h.in says:
/* Enable GNU extensions on systems that have them. */
For me it just seems that it's not a requirement so ./configure suceeds.
Or am I wrong and I can just assume that asprintf is avaible?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] Is it okay to just use GNU extensions or should an alternative be provided too?
2008-08-16 12:43 ` Felix Zielcke
@ 2008-08-16 12:54 ` Vesa Jääskeläinen
2008-08-16 12:58 ` Robert Millan
1 sibling, 0 replies; 8+ messages in thread
From: Vesa Jääskeläinen @ 2008-08-16 12:54 UTC (permalink / raw)
To: The development of GRUB 2
Felix Zielcke wrote:
> But yeah maybe there's even in the kernel a use for asprintf,
> so maybe a good idea to make a grub_asprintf?
> This could be then either always used even if the util/*.c use the
> library functions normally or it could be done as with my
> grub_print_error change :)
It would be security feature to use automatic allocation of the memory
for needed amount of the memory. Then it is not possible to do buffer
overflow with those functions. So I have nothing against that. And in
anyway it is only small wrapper to snprintf and malloc so size impact
should not be too big either. Perhaps it can save space later on.
But about using string formatters from different systems can be
problematic. As on some systems differ what different specifiers do.
Good examples are cases where string can be wide char or ansi, or where
length of the integer can change.
When using it with grub's own formatters we know exactly how they perform.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC] Is it okay to just use GNU extensions or should an alternative be provided too?
2008-08-16 12:43 ` Felix Zielcke
2008-08-16 12:54 ` Vesa Jääskeläinen
@ 2008-08-16 12:58 ` Robert Millan
1 sibling, 0 replies; 8+ messages in thread
From: Robert Millan @ 2008-08-16 12:58 UTC (permalink / raw)
To: The development of GRUB 2
On Sat, Aug 16, 2008 at 02:43:13PM +0200, Felix Zielcke wrote:
> Am Samstag, den 16.08.2008, 15:32 +0300 schrieb Vesa Jääskeläinen:
> >
> > Please use what ever we have on grub source code already. Then it work
> > fine also in standalone grub.
>
> Maybe this time my mail was a bit too short? :)
> especially, I ask for asprintf in util/misc.c so just GRUB_UTIL.
>
> But Marco and I thought it would be good to make a general discussion
> about GNU extentions.
> GCC is needed anyway because of the nested function but what about glibc
> or other stuff?
For code that is to be shared with real GRUB, we should only use GRUB's own
functions, so there's no concern there.
For util/ code, IMO we should be careful not to break other systems. GCC is
widely available, so it's not such a big concern, but not so for Glibc.
In general, I think we should avoid the complication of implementing two
versions of our code (one with GNU-isms and one without) by only implementing
the portable one.
As for asprintf, I think unless/untill someone reports that it is missing on
a system where GRUB is usable (i.e. where we have loaders for their kernel),
we shouldn't worry about it.
> But yeah maybe there's even in the kernel a use for asprintf,
> so maybe a good idea to make a grub_asprintf?
Probably not (because of space reasons), unless we find it terribly needed.
But it's also possible to have it in real GRUB without having it in kernel.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-08-16 12:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-16 12:05 [RFC] Is it okay to just use GNU extensions or should an alternative be provided too? Felix Zielcke
2008-08-16 12:32 ` Vesa Jääskeläinen
2008-08-16 12:39 ` Robert Millan
2008-08-16 12:43 ` Felix Zielcke
2008-08-16 12:54 ` Vesa Jääskeläinen
2008-08-16 12:58 ` Robert Millan
2008-08-16 12:39 ` Robert Millan
2008-08-16 12:48 ` Felix Zielcke
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.