From owner-freebsd-current@FreeBSD.ORG Mon Jul 9 20:08:38 2007 Return-Path: X-Original-To: freebsd-current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8E96D16A469 for ; Mon, 9 Jul 2007 20:08:38 +0000 (UTC) (envelope-from scf@FreeBSD.org) Received: from mail.farley.org (farley.org [67.64.95.201]) by mx1.freebsd.org (Postfix) with ESMTP id 55DF513C4C1 for ; Mon, 9 Jul 2007 20:08:38 +0000 (UTC) (envelope-from scf@FreeBSD.org) Received: from thor.farley.org (thor.farley.org [192.168.1.5]) by mail.farley.org (8.14.1/8.14.1) with ESMTP id l69K99gN023711; Mon, 9 Jul 2007 15:09:09 -0500 (CDT) (envelope-from scf@FreeBSD.org) Date: Mon, 9 Jul 2007 15:07:42 -0500 (CDT) From: "Sean C. Farley" To: Dirk Meyer In-Reply-To: Message-ID: <20070709145418.T52164@thor.farley.org> References: <20070703182400.Q1449@baba.farley.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.1 X-Spam-Checker-Version: SpamAssassin 3.2.1 (2007-05-02) on mail.farley.org Cc: freebsd-current@FreeBSD.org Subject: Re: HEADS UP: getenv() and family API change X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2007 20:08:38 -0000 On Sun, 8 Jul 2007, Dirk Meyer wrote: > Hallo Sean C. Farley, > >> Changes in moving to POSIX from historic BSD API: >> b. putenv takes a char * instead of const char *. >> c. putenv no longer makes a copy of the input string. > > Can you give more details? > > An application will break in using this: > putenv("PATH=/bin") > > now taking a char *, this will break with gcc42. True. As Andrey said, you should pass a copy of a const string into putenv(). putenv() is designed to allow changing a value at any time by manipulating the string. This is why I really wish the Open Group would just remove this function. While they are at it, they should remove direct access to environ. Some helper functions would be best. I rant every time I think about putenv() and an exposed environ variable. :) The best is to replace putenv() with setenv() in any applications with issues as it is less error-prone. Sean -- scf@FreeBSD.org