Bug 919953

Summary: Namespace clash for TMP_MAX in gluster code on OSX
Product: [Community] GlusterFS Reporter: Justin Clift <jclift>
Component: buildAssignee: Amar Tumballi <amarts>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: low Docs Contact:
Priority: unspecified    
Version: mainlineCC: gluster-bugs, kwade, vraman
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glusterfs-3.4.0 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-24 17:20:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Justin Clift 2013-03-11 01:20:55 UTC
Description of problem:

  Gluster defines TMP_MAX in it's source, but this is already
  provided system wide in OSX in stdio.h.

  $ grep TMP_MAX libglusterfs/src/common-utils.h 
  #define TMP_MAX              238328

  $ grep TMP_MAX /usr/include/stdio.h 
  #define	TMP_MAX		308915776


Version-Release number of selected component (if applicable):

  upstream gluster git master head, as of Sun 10th March 2013


How reproducible:

  Every time.

Steps to Reproduce:
1. git clone upstream git
2. ./autogen.sh; ./configure --disable-fuse-client; make
  
Actual results:

Many many warnings about TMP_MAX being defined when compiling gluster.

Small sample below

**********************************************************************

In file included from event-poll.c:22:
common-utils.h:33:1: warning: "TMP_MAX" redefined
In file included from logging.h:20,
                 from event-poll.c:19:
/usr/include/stdio.h:212:1: warning: this is the location of the previous definition
glibtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../.. -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DGF_DARWIN_HOST_OS -I../../libglusterfs/src -I../../contrib/uuid -D__USE_FILE_OFFSET64 -DXLATORDIR=\"/tmp/gluster/lib/glusterfs/3git/xlator\" -I../../contrib/rbtree -Wall -I../../argp-standalone -D__DARWIN_64_BIT_INO_T -bundle -undefined suppress -flat_namespace -D_XOPEN_SOURCE -O0 -DTHREAD_UNSAFE_BASENAME -DTHREAD_UNSAFE_DIRNAME -DDATADIR=\"/tmp/gluster/var\" -O2 -g -Wformat -Werror=format-security -MT libglusterfs_la-event-poll.lo -MD -MP -MF .deps/libglusterfs_la-event-poll.Tpo -c event-poll.c -o libglusterfs_la-event-poll.o >/dev/null 2>&1
glibtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../.. -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DGF_DARWIN_HOST_OS -I../../libglusterfs/src -I../../contrib/uuid -D__USE_FILE_OFFSET64 -DXLATORDIR=\"/tmp/gluster/lib/glusterfs/3git/xlator\" -I../../contrib/rbtree -Wall -I../../argp-standalone -D__DARWIN_64_BIT_INO_T -bundle -undefined suppress -flat_namespace -D_XOPEN_SOURCE -O0 -DTHREAD_UNSAFE_BASENAME -DTHREAD_UNSAFE_DIRNAME -DDATADIR=\"/tmp/gluster/var\" -O2 -g -Wformat -Werror=format-security -MT libglusterfs_la-event-epoll.lo -MD -MP -MF .deps/libglusterfs_la-event-epoll.Tpo -c event-epoll.c  -fno-common -DPIC -o .libs/libglusterfs_la-event-epoll.o
In file included from event-epoll.c:22:
common-utils.h:33:1: warning: "TMP_MAX" redefined
In file included from logging.h:20,
                 from event-epoll.c:19:
/usr/include/stdio.h:212:1: warning: this is the location of the previous definition
glibtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../.. -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DGF_DARWIN_HOST_OS -I../../libglusterfs/src -I../../contrib/uuid -D__USE_FILE_OFFSET64 -DXLATORDIR=\"/tmp/gluster/lib/glusterfs/3git/xlator\" -I../../contrib/rbtree -Wall -I../../argp-standalone -D__DARWIN_64_BIT_INO_T -bundle -undefined suppress -flat_namespace -D_XOPEN_SOURCE -O0 -DTHREAD_UNSAFE_BASENAME -DTHREAD_UNSAFE_DIRNAME -DDATADIR=\"/tmp/gluster/var\" -O2 -g -Wformat -Werror=format-security -MT libglusterfs_la-event-epoll.lo -MD -MP -MF .deps/libglusterfs_la-event-epoll.Tpo -c event-epoll.c -o libglusterfs_la-event-epoll.o >/dev/null 2>&1
glibtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../.. -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DGF_DARWIN_HOST_OS -I../../libglusterfs/src -I../../contrib/uuid -D__USE_FILE_OFFSET64 -DXLATORDIR=\"/tmp/gluster/lib/glusterfs/3git/xlator\" -I../../contrib/rbtree -Wall -I../../argp-standalone -D__DARWIN_64_BIT_INO_T -bundle -undefined suppress -flat_namespace -D_XOPEN_SOURCE -O0 -DTHREAD_UNSAFE_BASENAME -DTHREAD_UNSAFE_DIRNAME -DDATADIR=\"/tmp/gluster/var\" -O2 -g -Wformat -Werror=format-security -MT libglusterfs_la-y.tab.lo -MD -MP -MF .deps/libglusterfs_la-y.tab.Tpo -c y.tab.c  -fno-common -DPIC -o .libs/libglusterfs_la-y.tab.o
In file included from circ-buff.h:14,
                 from event-history.h:20,
                 from xlator.h:23,
                 from ./graph.y:24:
common-utils.h:33:1: warning: "TMP_MAX" redefined
In file included from ./graph.y:14:
/usr/include/stdio.h:212:1: warning: this is the location of the previous definition
glibtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../.. -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DGF_DARWIN_HOST_OS -I../../libglusterfs/src -I../../contrib/uuid -D__USE_FILE_OFFSET64 -DXLATORDIR=\"/tmp/gluster/lib/glusterfs/3git/xlator\" -I../../contrib/rbtree -Wall -I../../argp-standalone -D__DARWIN_64_BIT_INO_T -bundle -undefined suppress -flat_namespace -D_XOPEN_SOURCE -O0 -DTHREAD_UNSAFE_BASENAME -DTHREAD_UNSAFE_DIRNAME -DDATADIR=\"/tmp/gluster/var\" -O2 -g -Wformat -Werror=format-security -MT libglusterfs_la-y.tab.lo -MD -MP -MF .deps/libglusterfs_la-y.tab.Tpo -c y.tab.c -o libglusterfs_la-y.tab.o >/dev/null 2>&1
glibtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../.. -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DGF_DARWIN_HOST_OS -I../../libglusterfs/src -I../../contrib/uuid -D__USE_FILE_OFFSET64 -DXLATORDIR=\"/tmp/gluster/lib/glusterfs/3git/xlator\" -I../../contrib/rbtree -Wall -I../../argp-standalone -D__DARWIN_64_BIT_INO_T -bundle -undefined suppress -flat_namespace -D_XOPEN_SOURCE -O0 -DTHREAD_UNSAFE_BASENAME -DTHREAD_UNSAFE_DIRNAME -DDATADIR=\"/tmp/gluster/var\" -O2 -g -Wformat -Werror=format-security -MT libglusterfs_la-graph.lex.lo -MD -MP -MF .deps/libglusterfs_la-graph.lex.Tpo -c graph.lex.c  -fno-common -DPIC -o .libs/libglusterfs_la-graph.lex.o
In file included from circ-buff.h:14,
                 from event-history.h:20,
                 from xlator.h:23,
                 from ./graph.l:17:
common-utils.h:33:1: warning: "TMP_MAX" redefined
In file included from <stdout>:19:
/usr/include/stdio.h:212:1: warning: this is the location of the previous definition

**********************************************************************

Expected results:

  Normal compilation with no warnings about TMP_MAX being redefined.

Additional info:

  TMP_MAX appears to be used only in one place the source, so renaming
  it to avoid the namespace conflict might be very possible.

  $ grep -ri TMP_MAX *
  contrib/stdlib/gf_mkostemp.c:           conform to POSIX, this must be no smaller than TMP_MAX.  */
  contrib/stdlib/gf_mkostemp.c:#if ATTEMPTS_MIN < TMP_MAX
  contrib/stdlib/gf_mkostemp.c:        unsigned int attempts = TMP_MAX;
  libglusterfs/src/common-utils.h:#define TMP_MAX              238328

Comment 1 Justin Clift 2013-03-11 01:35:34 UTC
Potential fix here:

  http://review.gluster.org/4654

Comment 2 Vijay Bellur 2013-03-13 17:33:19 UTC
CHANGE: http://review.gluster.org/4654 (Renamed TMP_MAX to GF_TMP_MAX to avoid namespace clash on OSX.) merged in master by Vijay Bellur (vbellur)