From patchwork Fri Jul 17 08:30:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 40123 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CE7E6393BC0F; Fri, 17 Jul 2020 08:30:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE7E6393BC0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594974632; bh=HDwHa/1D0xBVegOUjGk9Tl9vproyQ3d8kbiHdbzVo3Y=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mi/SgIr/ZFN1faIXk+jJf2gTUWBvDo55Fn46pa1fmAv0CpXwf0UGFBDKnm74O1CHJ fzumwO/wgO4GXHKi+4lqWRxUinFiEaUJoC6Na7+0Hf4+JZsVL2cfBd3iguP6udox3y pY8CHgU3nrD95ac51ZTGfWOtxTX9VQ2sEses7E4A= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 04358393B078 for ; Fri, 17 Jul 2020 08:30:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 04358393B078 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-48-1mOAv6EvOrqh7izIIySTaA-1; Fri, 17 Jul 2020 04:30:28 -0400 X-MC-Unique: 1mOAv6EvOrqh7izIIySTaA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2145680572E for ; Fri, 17 Jul 2020 08:30:28 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-136.ams2.redhat.com [10.36.112.136]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25F117B41F for ; Fri, 17 Jul 2020 08:30:26 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 04/11] nss_files: Use generic result pointer in parse_line In-Reply-To: References: Message-Id: <92c7e280f16600bd2f74109c243668b9e4ed87b0.1594974444.git.fweimer@redhat.com> Date: Fri, 17 Jul 2020 10:30:25 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" As a result, all parse_line functions have the same prototype, except for that producing struct hostent. This change is ABI-compatible, so it does not alter the internal GLIBC_PRIVATE ABI (otherwise we should probably have renamed the exported functions). A future change will use this to implement a generict fget*ent_r function. Tested-by: Carlos O'Donell Reviewed-by: Carlos O'Donell --- include/nss_files.h | 48 ++++++++++--------------------------- nss/nss_files/files-parse.c | 5 ++-- 2 files changed, 15 insertions(+), 38 deletions(-) diff --git a/include/nss_files.h b/include/nss_files.h index 54b354afb3..d0f26815b5 100644 --- a/include/nss_files.h +++ b/include/nss_files.h @@ -26,45 +26,21 @@ FILE *__nss_files_fopen (const char *path); libc_hidden_proto (__nss_files_fopen) struct parser_data; -struct etherent; -struct group; -struct netent; -struct passwd; -struct protoent; -struct rpcent; -struct servent; -struct sgrp; -struct spwd; /* Instances of the parse_line function from nss/nss_files/files-parse.c. */ -extern int _nss_files_parse_etherent (char *line, struct etherent *result, - struct parser_data *data, - size_t datalen, int *errnop); -extern int _nss_files_parse_grent (char *line, struct group *result, - struct parser_data *data, - size_t datalen, int *errnop); -extern int _nss_files_parse_netent (char *line, struct netent *result, - struct parser_data *data, - size_t datalen, int *errnop); -extern int _nss_files_parse_protoent (char *line, struct protoent *result, - struct parser_data *data, - size_t datalen, int *errnop); -extern int _nss_files_parse_pwent (char *line, struct passwd *result, - struct parser_data *data, - size_t datalen, int *errnop); -extern int _nss_files_parse_rpcent (char *line, struct rpcent *result, - struct parser_data *data, - size_t datalen, int *errnop); -extern int _nss_files_parse_servent (char *line, struct servent *result, - struct parser_data *data, - size_t datalen, int *errnop); -extern int _nss_files_parse_sgent (char *line, struct sgrp *result, - struct parser_data *data, - size_t datalen, int *errnop); -extern int _nss_files_parse_spent (char *line, struct spwd *result, - struct parser_data *data, - size_t datalen, int *errnop); +typedef int nss_files_parse_line (char *line, void *result, + struct parser_data *data, + size_t datalen, int *errnop); +extern nss_files_parse_line _nss_files_parse_etherent; +extern nss_files_parse_line _nss_files_parse_grent; +extern nss_files_parse_line _nss_files_parse_netent; +extern nss_files_parse_line _nss_files_parse_protoent; +extern nss_files_parse_line _nss_files_parse_pwent; +extern nss_files_parse_line _nss_files_parse_rpcent; +extern nss_files_parse_line _nss_files_parse_servent; +extern nss_files_parse_line _nss_files_parse_sgent; +extern nss_files_parse_line _nss_files_parse_spent; libnss_files_hidden_proto (_nss_files_parse_etherent) libc_hidden_proto (_nss_files_parse_grent) diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c index 382028765b..c6cd43babe 100644 --- a/nss/nss_files/files-parse.c +++ b/nss/nss_files/files-parse.c @@ -87,7 +87,7 @@ struct parser_data #ifdef EXTERN_PARSER /* The parser is defined in a different module. */ -extern int parse_line (char *line, struct STRUCTURE *result, +extern int parse_line (char *line, void *result, struct parser_data *data, size_t datalen, int *errnop EXTRA_ARGS_DECL); @@ -99,10 +99,11 @@ extern int parse_line (char *line, struct STRUCTURE *result, # define LINE_PARSER(EOLSET, BODY) \ parser_stclass int \ -parse_line (char *line, struct STRUCTURE *result, \ +parse_line (char *line, void *generic_result, \ struct parser_data *data, size_t datalen, int *errnop \ EXTRA_ARGS_DECL) \ { \ + struct STRUCTURE *result = generic_result; \ ENTDATA_DECL (data) \ BUFFER_PREPARE \ char *p = strpbrk (line, EOLSET "\n"); \