Bug 24088 - Avoid usage of get_current_dir_name() on non-GNU targets.
Summary: Avoid usage of get_current_dir_name() on non-GNU targets.
Status: RESOLVED FIXED
Alias: None
Product: libopenraw
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: Other BSD (Others)
: medium normal
Assignee: Hubert Figuiere
QA Contact:
URL:
Whiteboard: [release:0.1.0]
Keywords:
: 32657 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-09-22 11:14 UTC by zuxez
Modified: 2016-11-27 05:43 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Guard get_current_dir_name. If not available, fall back to getcwd(). (1.24 KB, patch)
2009-09-22 11:14 UTC, zuxez
Details | Splinter Review

Description zuxez 2009-09-22 11:14:02 UTC
Created attachment 29765 [details] [review]
Guard get_current_dir_name. If not available, fall back to getcwd().

The testsuite uses get_current_dir_name() to determine the current directory for the bootstrap download of the images. Unfortunately this function is a GNU-extension and thus not available on platforms that
aren't GNU (MacOSX Snow Leopard in this case). The result is a compilation error for the test suite.

It can be fixed by guarding get_current_dir_name() with _GNU_SOURCE and if it's not available fall back to POSIX getcwd(). The attached patch does that. Test suite has been tested with the patch on the aforementioned Snow Leopard as well as on Linux 2.6.31.
Comment 1 Hubert Figuiere 2009-11-04 21:28:33 UTC
The patch never release the memory allocated by malloc()

Also I'd rather have the function detected by configure rather than have a check on _GNU_SOURCE. I can't really apply it like that.
Comment 2 zuxez 2009-11-04 23:54:45 UTC
(In reply to comment #1)
> The patch never release the memory allocated by malloc()
> 
> Also I'd rather have the function detected by configure rather than have a
> check on _GNU_SOURCE. I can't really apply it like that.
> 

The memory is freed in the line right after the patch chunk: free(dir); The malloc that needs to be done explicitly for getcwd() is done implicitly by get_current_dir_name(), so for both you need to free the memory, anyway, which is done.

Well, go ahead and detect the function with configure and change the guard's name appropriately. There should have already been a check for being a GNU-box, though.
Comment 3 Hubert Figuiere 2009-11-05 07:35:18 UTC
(In reply to comment #2)

> The memory is freed in the line right after the patch chunk: free(dir); The
> malloc that needs to be done explicitly for getcwd() is done implicitly by
> get_current_dir_name(), so for both you need to free the memory, anyway, which
> is done.

My bad. Sorry about that I didn't read properly
 
> Well, go ahead and detect the function with configure and change the guard's
> name appropriately. There should have already been a check for being a GNU-box,
> though.

Why a "check for being a GNU-box"?

Comment 4 Hubert Figuiere 2010-03-04 23:48:22 UTC
I pushed a fix to git master for next release.
Comment 5 Hubert Figuiere 2010-12-26 05:24:45 UTC
*** Bug 32657 has been marked as a duplicate of this bug. ***


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.