Suggested better fix for putenv()
Derek Atkins
warlord@MIT.EDU
16 Nov 2001 23:57:36 -0500
On Solaris, there is no guarantee that putenv will return -1 on
error. The man page on Solaris specifically says:
RETURN VALUES
The putenv() functions returns a non-zero value if it was
unable to obtain enough space using malloc(3C) for an
expanded environment. Otherwise, 0 is returned.
This implies to me that we should check for the return val != 0
instead of return val == -1. The included patch fixes this.
Also, shouldn't gnc-module.c include config.h?
-derek
Index: src/gnc-module/gnc-module.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnc-module/gnc-module.c,v
retrieving revision 1.12
diff -u -r1.12 gnc-module.c
--- src/gnc-module/gnc-module.c 2001/11/17 04:01:01 1.12
+++ src/gnc-module/gnc-module.c 2001/11/17 04:56:20
@@ -129,7 +129,7 @@
g_list_free(dirs);
put_str = g_strdup_printf ("LD_LIBRARY_PATH=%s", envt);
- if(putenv(put_str) == -1)
+ if(putenv(put_str) != 0)
{
g_warning ("gnc-module failed to set LD_LIBRARY_PATH");
}
--
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board (SIPB)
URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
warlord@MIT.EDU PGP key available