Is it okay to just use GNU extensions or should an alternative be provided too?
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.
Quoted 5 lines · Felix Zielcke
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
Quoted 8 lines
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.
Quoted 3 lines · Vesa Jääskeläinen
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.
Signature · 5 lines
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."
Am Samstag, den 16.08.2008, 15:32 +0300 schrieb Vesa Jääskeläinen:
Quoted 3 lines
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?
Quoted 3 lines
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 :)
Quoted 5 lines · Felix Zielcke
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 mygrub_print_errorchange :)
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.
Quoted 5 lines · Felix Zielcke
Am Samstag, den 16.08.2008, 15:32 +0300 schrieb Vesa Jääskeläinen:
Quoted 3 lines
Please use what ever we have on grub source code already. Then it work fine also in standalone grub.
Quoted 7 lines
Maybe this time my mail was a bit too short? :) especially, I ask for asprintf in
util/misc.cso justGRUB_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.
Quoted 2 lines
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.
Signature · 5 lines
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."
Quoted 6 lines · Felix Zielcke
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/BuildingOnNonGnuSo 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.
Quoted 1 line
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.
Signature · 5 lines
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."
Am Samstag, den 16.08.2008, 14:39 +0200 schrieb Robert Millan:
Quoted 9 lines · Felix Zielcke
Quoted 6 lines
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/BuildingOnNonGnuSo 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.
Quoted 6 lines
Quoted 1 line
I doubt it would be good to use many `#ifdef
_GNU_SOURCE' in the code.
_GNU_SOURCEis 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?