diff mbox

i2c-tools: fix feature test macros for glibc >= 2.20

Message ID 1470213836-2848-1-git-send-email-wsa@the-dreams.de
State Superseded
Headers show

Commit Message

Wolfram Sang Aug. 3, 2016, 8:43 a.m. UTC
Since glibc 2.20, the usage of _BSD_SOURCE is deprecated. Fix it like
described here:

https://sourceware.org/glibc/wiki/Release/2.20#Deprecation_of__BSD_SOURCE_and__SVID_SOURCE_feature_macros

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 tools/i2cbusses.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jean Delvare Aug. 3, 2016, 11:23 a.m. UTC | #1
Hi Wolfram,

On Wed,  3 Aug 2016 10:43:56 +0200, Wolfram Sang wrote:
> Since glibc 2.20, the usage of _BSD_SOURCE is deprecated. Fix it like
> described here:
> 
> https://sourceware.org/glibc/wiki/Release/2.20#Deprecation_of__BSD_SOURCE_and__SVID_SOURCE_feature_macros
> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> ---
>  tools/i2cbusses.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/i2cbusses.c b/tools/i2cbusses.c
> index b3093aa..28e3682 100644
> --- a/tools/i2cbusses.c
> +++ b/tools/i2cbusses.c
> @@ -23,7 +23,8 @@
>  */
>  
>  /* For strdup and snprintf */
> -#define _BSD_SOURCE 1
> +#define _BSD_SOURCE 1 /* for glibc < 2.19 */
> +#define _DEFAULT_SOURCE 1 /* for glibc >= 2.20 */

Actually >= 2.19 if I read the web page you mentioned (which has the
same "bug") correctly.

Other than that,

Reviewed-by: Jean Delvare <jdelvare@suse.de>

Again the 3.1 branch would need the same fix.

>  
>  #include <sys/types.h>
>  #include <sys/stat.h>

Thanks,
Wolfram Sang Aug. 9, 2016, 8:40 p.m. UTC | #2
> >  /* For strdup and snprintf */
> > -#define _BSD_SOURCE 1
> > +#define _BSD_SOURCE 1 /* for glibc < 2.19 */
> > +#define _DEFAULT_SOURCE 1 /* for glibc >= 2.20 */
> 
> Actually >= 2.19 if I read the web page you mentioned (which has the
> same "bug") correctly.

On the web page it is not a bug, because it says "If ... you must
support glibc < 2.19 and glibc >= 2.20 then define all three
unconditionally". This is correct since 2.19 works with both options.

However, I should probably use >= 2.19 and <= 2.19 here.

> Reviewed-by: Jean Delvare <jdelvare@suse.de>
> 
> Again the 3.1 branch would need the same fix.

Yes.
Wolfram Sang Aug. 12, 2016, 6:34 p.m. UTC | #3
On Wed, Aug 03, 2016 at 10:43:56AM +0200, Wolfram Sang wrote:
> Since glibc 2.20, the usage of _BSD_SOURCE is deprecated. Fix it like
> described here:
> 
> https://sourceware.org/glibc/wiki/Release/2.20#Deprecation_of__BSD_SOURCE_and__SVID_SOURCE_feature_macros
> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

Pushed to master and 3.1-branch.
diff mbox

Patch

diff --git a/tools/i2cbusses.c b/tools/i2cbusses.c
index b3093aa..28e3682 100644
--- a/tools/i2cbusses.c
+++ b/tools/i2cbusses.c
@@ -23,7 +23,8 @@ 
 */
 
 /* For strdup and snprintf */
-#define _BSD_SOURCE 1
+#define _BSD_SOURCE 1 /* for glibc < 2.19 */
+#define _DEFAULT_SOURCE 1 /* for glibc >= 2.20 */
 
 #include <sys/types.h>
 #include <sys/stat.h>