From mboxrd@z Thu Jan 1 00:00:00 1970 From: Panu Matilainen Subject: Re: [PATCH 2/2] devargs: remove limit on parameters length Date: Thu, 08 Jan 2015 11:15:47 +0200 Message-ID: <54AE4AC3.80205@laiskiainen.org> References: <1420635809-30976-1-git-send-email-david.marchand@6wind.com> <1420635809-30976-3-git-send-email-david.marchand@6wind.com> <20150107145900.2a139ee6@urahara> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <20150107145900.2a139ee6@urahara> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" On 01/08/2015 12:59 AM, Stephen Hemminger wrote: > On Wed, 7 Jan 2015 14:03:29 +0100 > David Marchand wrote: > >> + buf = strdup(devargs_str); >> + if (buf == NULL) { >> + RTE_LOG(ERR, EAL, "cannot allocate temp memory for devargs\n"); >> + goto fail; >> + } >> + > > If string is only used in same function you might consider using strdupa() which avoids > worrying about freeing in error paths. > It also "frees" you from having to worry about failures in the first place because alloca() failures are not nice and catchable, its undefined behavior. If arbitrary length parameters is the goal then using the alloca() family of functions is replacing a controlled failure with an unpredictable crash. - Panu -