From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33136 invoked by alias); 27 Apr 2015 18:54:43 -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 33123 invoked by uid 89); 27 Apr 2015 18:54:41 -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,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f46.google.com Received: from mail-wg0-f46.google.com (HELO mail-wg0-f46.google.com) (74.125.82.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 27 Apr 2015 18:54:39 +0000 Received: by wgen6 with SMTP id n6so126111411wge.3 for ; Mon, 27 Apr 2015 11:54:36 -0700 (PDT) X-Received: by 10.180.74.238 with SMTP id x14mr23623112wiv.81.1430160876526; Mon, 27 Apr 2015 11:54:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.33.135 with HTTP; Mon, 27 Apr 2015 11:54:16 -0700 (PDT) In-Reply-To: <553E7994.5040303@redhat.com> References: <553E6D2E.7060403@redhat.com> <553E7994.5040303@redhat.com> From: Bruce Korb Date: Mon, 27 Apr 2015 18:54:00 -0000 Message-ID: Subject: Re: pass by value and also snprintf() To: Richard Henderson Cc: libffi-discuss@sourceware.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015/txt/msg00070.txt.bz2 Hi Richard, THANK YOU!! > 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... Indeed. Worthy of a BOLD caveat in the docs. Googling seems to point mostly here: http://www.atmark-techno.com/~yashi/libffi.html but it looks like my info doc, so I hope it is up to date. Anyway, it was there where I also saw that funny comment about altering passed values. Based on my understanding of C and calling conventions, it seems pretty impossible for a callee to alter a caller's value when passed by value, even if one goes through libffi, so what is that comment trying to say? (RE: ffi_call()) Anyway, again, thank you! Regards, Bruce