Re: [PATCH] Use setenv(), fix warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



And Timo Hirvonen writes:
 - It appears that statically allocated strings are accepted but 
 - _automatic_ variables aren't.

The putenv()-ed string has to exist as long as the environment
does.  You can twiddle the environment just by twiddling the
string you registered.  What fun!

 - I noticed setenv is now in compat/ so I though it was good idea
 - to use it.

All uses of putenv() originally were setenv().  I finally realized
a compat/setenv.c was better than playing whack-a-setenv on every
release...  (Ah, hindsight.)

Note that the current compat/setenv.c _LEAKS MEMORY_ on purpose.  
Because putenv() requires the string to stay around, we can't
ever free it.  I hope any library implementing bits of git
(libgitbit?) avoids setting environment variables.

 - So the variable is emptied, not removed.  But usually empty environment
 - variables are treated as if they didn't exist...

More specifically, git treats both "" and NULL as empty, or at 
least it did last time I checked.

Jason
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]