Received: from eggs.gnu.org ([2001:4830:134:3::10]:58384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbr0M-0008Ed-7l for qemu-devel@nongnu.org; Mon, 22 Aug 2016 11:19:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bbr0J-0006fM-Ib for qemu-devel@nongnu.org; Mon, 22 Aug 2016 11:19:14 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:33582) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbr0J-0006fF-EI for qemu-devel@nongnu.org; Mon, 22 Aug 2016 11:19:11 -0400 Received: by mail-qk0-x243.google.com with SMTP id n66so5204127qkf.0 for ; Mon, 22 Aug 2016 08:19:11 -0700 (PDT) Sender: Richard Henderson References: <1471871071-17819-1-git-send-email-pl@kamp.de> <1471871071-17819-2-git-send-email-pl@kamp.de> From: Richard Henderson Message-ID: Date: Mon, 22 Aug 2016 08:19:06 -0700 MIME-Version: 1.0 In-Reply-To: <1471871071-17819-2-git-send-email-pl@kamp.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V6 1/6] oslib-posix: add helpers for stack alloc and free List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven , qemu-devel@nongnu.org Cc: kwolf@redhat.com, mreitz@redhat.com, pbonzini@redhat.com, mst@redhat.com, dgilbert@redhat.com, peter.maydell@linaro.org, eblake@redhat.com, armbru@redhat.com On 08/22/2016 06:04 AM, Peter Lieven wrote: > +static size_t adjust_stack_size(size_t sz) > +{ > +#ifdef _SC_THREAD_STACK_MIN > + /* avoid stacks smaller than _SC_THREAD_STACK_MIN */ > + sz = MAX(MAX(sysconf(_SC_THREAD_STACK_MIN), 0), sz); > +#endif You need to place the sysconf result into a local variable. What you have now expands to 4 invocations of the function. You might also consider passing in the pagesize, since you've already called getpagesize in one of the two users of this function. r~