From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 34337 invoked by alias); 27 Apr 2015 18:02:00 -0000 Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org Received: (qmail 34280 invoked by uid 89); 27 Apr 2015 18:02:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 27 Apr 2015 18:01:59 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 1766B8E791; Mon, 27 Apr 2015 18:01:58 +0000 (UTC) Received: from anchor.twiddle.net (vpn-225-135.phx2.redhat.com [10.3.225.135]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3RI1vJS014368; Mon, 27 Apr 2015 14:01:57 -0400 Message-ID: <553E7994.5040303@redhat.com> Date: Mon, 27 Apr 2015 18:02:00 -0000 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Bruce Korb CC: libffi-discuss@sourceware.org Subject: Re: pass by value and also snprintf() References: <553E6D2E.7060403@redhat.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015/txt/msg00069.txt.bz2 On 04/27/2015 10:37 AM, Bruce Korb wrote: > int > main(int argc, char ** argv) > { > char buffer[0x1000]; > size_t bufsz = sizeof(buffer); > char const fmt[] = "Allocated sblock_id=%d for band_id=%d\n"; > int32_t sblock = 1; > int32_t band = 1; > void * fn = sprintf; ... > void * values[5] = { > [0] = buffer, > [1] = &bufsz, > [2] = UCONST(fmt), > [3] = &sblock, > [4] = &band }; That would be because you're passing buffer and fmt instead of a pointer to buffer and fmt. You need to do char * buffer_p = buffer; const char *fmt_p = fmt; void * values[5] = { [0] = &buffer_p, [1] = &bufsz, [2] = &fmt_p, [3] = &sblock, [4] = &band }; One of the many peculiarities of the libffi api... r~