After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 642783 - CamelLocalFolder: Let glibc's realpath() allocate for us
CamelLocalFolder: Let glibc's realpath() allocate for us
Status: RESOLVED FIXED
Product: evolution-data-server
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Evolution Shell Maintainers Team
Evolution QA team
Depends on:
Blocks:
 
 
Reported: 2011-02-19 22:45 UTC by Emilio Pozuelo Monfort
Modified: 2011-03-08 18:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Don't use PATH_MAX for portability reasons (1.93 KB, patch)
2011-02-19 22:47 UTC, Emilio Pozuelo Monfort
rejected Details | Review
Only use realpath(foo, NULL) when building with GNU libc (1.42 KB, patch)
2011-03-02 19:25 UTC, Emilio Pozuelo Monfort
committed Details | Review

Description Emilio Pozuelo Monfort 2011-02-19 22:45:52 UTC
Hi,

PATH_MAX is not portable, as it's not mandated by POSIX.

The attached patch uses dynamic allocation instead (realpath will allocate the necessary memory).

I haven't been able to test it because git master requires some newer stuff I don't have yet.
Comment 1 Emilio Pozuelo Monfort 2011-02-19 22:47:31 UTC
Created attachment 181366 [details] [review]
Don't use PATH_MAX for portability reasons
Comment 2 Matthew Barnes 2011-02-19 23:43:35 UTC
realpath() doesn't allocate memory.  You still have to pass it a buffer, and you still need PATH_MAX to know how large to make the buffer.  The POSIX documentation [1] hints that some implementations might return allocated memory if given a NULL buffer, but relying on this behavior is no more portable than using PATH_MAX.

If you can find a more portable workaround I'll consider it.  GLib or GIO might offer something similar.

[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/realpath.html
Comment 3 Emilio Pozuelo Monfort 2011-02-20 00:15:49 UTC
POSIX 2008 defines this behaviour:

" If resolved_name is a null pointer, the generated pathname shall be stored as a null-terminated string in a buffer allocated as if by a call to malloc(). "

http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html
Comment 4 Emilio Pozuelo Monfort 2011-03-02 19:25:30 UTC
Created attachment 182300 [details] [review]
Only use realpath(foo, NULL) when building with GNU libc

OK, how about this? glibc implements the POSIX.2008 behaviour, so it's fine, and we keep the PATH_MAX way for other platforms.
Comment 5 Matthew Barnes 2011-03-08 15:22:44 UTC
That looks good enough for now.  There's an old GLib enhancement request for this type of issue in bug #111848.  It's been getting some attention lately so maybe it will land soon and we can clean out all the messy #ifdef's.
Comment 6 Matthew Barnes 2011-03-08 17:50:02 UTC
Patch committed (with a few comments added) for 2.91.92:
http://git.gnome.org/browse/evolution-data-server/commit/?id=b60d2b8f74702cfa26e24ed67dede58fb9aabddc
Comment 7 Emilio Pozuelo Monfort 2011-03-08 18:10:05 UTC
Thanks. The glib function would be useful here indeed.