From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 449 invoked by alias); 22 Mar 2016 20:25:54 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 405 invoked by uid 89); 22 Mar 2016 20:25:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=nip, management, cheating X-HELO: mx1.redhat.com Subject: Re: Calling functions through a pointer of incorrect type To: Joseph Myers References: <56F10E3B.60300@redhat.com> Cc: GNU C Library From: Florian Weimer Message-ID: <56F1AA47.6040509@redhat.com> Date: Tue, 22 Mar 2016 20:25:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-03/txt/msg00582.txt.bz2 On 03/22/2016 08:14 PM, Joseph Myers wrote: > On Tue, 22 Mar 2016, Florian Weimer wrote: > >> Just a sanity check: It is no longer acceptable glibc coding style to >> call functions through mismatching pointer types. Correct? > > I think more specific examples would help so we can see if there are > cleaner approaches that generate the same code. (For example, it's > deliberate that in some places functions with incompatible C types but > compatible ABIs are aliased to each other.) I saw this in getaddrinfo: if (fct == NULL) /* We are cheating here. The gethostbyname2_r function does not have the same interface as gethostbyname3_r but the extra arguments the latter takes are added at the end. So the gethostbyname2_r code will just ignore them. */ fct = __nss_lookup_function (nip, "gethostbyname2_r"); The void ** vs concrete pointer example is __nss_getent. For __nss_getent, it wouldn't be too hard to split the buffer management from the call, and move the call to the caller of __nss_getent, where the correct type is known. getaddrinfo may be harder and involve splitting the code around the caller. Florian