Bug 67229

Summary: [PATCH] fix build on GNU/Hurd
Product: libxkbcommon Reporter: Pino Toscano <toscano.pino>
Component: GeneralAssignee: Daniel Stone <daniel>
Status: RESOLVED FIXED QA Contact: Ran Benita <ran234>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: All   
OS: other   
Whiteboard:
i915 platform: i915 features:
Attachments: Get rid of the usage of PATH_MAX
Get rid of the usage of PATH_MAX

Description Pino Toscano 2013-07-23 20:33:27 UTC
Created attachment 82874 [details] [review]
Get rid of the usage of PATH_MAX

Currently, libxkbcommon does not compile on GNU/Hurd; this happens because on the Hurd PATH_MAX (optional in POSIX) is not provided, while such constant is unconditionally used in two places (a source of the main library, and in the test suite).

Attached there is a patch that gets rid of the PATH_MAX usages, allocating and freeing buffers as needed. To avoid too many malloc/free in the for loop in FindFileInXkbPath, a buffer is grown according to the size needed at each iteration.
Comment 1 Ran Benita 2013-07-24 07:39:50 UTC
Comment on attachment 82874 [details] [review]
Get rid of the usage of PATH_MAX

Review of attachment 82874 [details] [review]:
-----------------------------------------------------------------

The patch looks good (we have src/darray.h which can do some of the boilerplate but that's fine here).
Can you create the patch though with 'git format-patch' rather than 'git diff' (with commit message and author etc.) so we can apply it?
Comment 2 Pino Toscano 2013-07-24 08:20:15 UTC
(In reply to comment #1)
> The patch looks good (we have src/darray.h which can do some of the
> boilerplate but that's fine here).

It seems darray doesn't handle malloc/realloc failures though.

> Can you create the patch though with 'git format-patch' rather than 'git
> diff' (with commit message and author etc.) so we can apply it?

Sure, here it is.
Comment 3 Pino Toscano 2013-07-24 08:21:00 UTC
Created attachment 82904 [details] [review]
Get rid of the usage of PATH_MAX
Comment 4 Ran Benita 2013-07-24 09:19:17 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > The patch looks good (we have src/darray.h which can do some of the
> > boilerplate but that's fine here).
> 
> It seems darray doesn't handle malloc/realloc failures though.

Yes, OOM handling is a "TODO" so to speak (the main problem being around the parser / keymap compiler).

> > Can you create the patch though with 'git format-patch' rather than 'git
> > diff' (with commit message and author etc.) so we can apply it?
> 
> Sure, here it is.

Thanks!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.