From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 502BA385140C for ; Mon, 19 Jul 2021 19:16:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 502BA385140C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 16JJFOTi010764; Mon, 19 Jul 2021 14:15:24 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 16JJFOSr010763; Mon, 19 Jul 2021 14:15:24 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 19 Jul 2021 14:15:24 -0500 From: Segher Boessenkool To: Bill Schmidt Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH 10/55] rs6000: Main function with stubs for parsing and output Message-ID: <20210719191524.GP1583@gate.crashing.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, TXREP, T_SPF_HELO_PERMERROR, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jul 2021 19:16:26 -0000 Hi! On Thu, Jun 17, 2021 at 10:18:54AM -0500, Bill Schmidt wrote: > * config/rs6000/rs6000-gen-builtins.c (rbtree.h): New #include. > (num_bifs): New variable. > (num_ovld_stanzas): Likewise. > (num_ovlds): Likewise. > (parse_codes): New enum. > (bif_rbt): New variable. > (ovld_rbt): Likewise. > (fntype_rbt): Likewise. > (bifo_rbt): Likewise. > (parse_bif): New stub function. > (create_bif_order): Likewise. > (parse_ovld): Likewise. > (write_header_file): Likewise. > (write_init_file): Likewise. > (write_defines_file): Likewise. > (delete_output_files): New function. > (main): Likewise. > +/* Parse the built-in file. */ > +static parse_codes > +parse_bif (void) > +{ > + return PC_OK; > +} Baby steps :-) > +/* Write everything to the header file (rs6000-builtins.h). */ > +static int > +write_header_file (void) > +{ > + return 1; > +} What does the return value mean? Please document it in a comment. Same for other functions (where the function name does not make it obvious what the return value is). > +static void > +delete_output_files (void) > +{ > + /* Depending on whence we're called, some of these may already be > + closed. Don't check for errors. */ > + fclose (header_file); > + fclose (init_file); > + fclose (defines_file); > + > + unlink (header_path); > + unlink (init_path); > + unlink (defines_path); > +} What are header_path etc.? It is a very good idea to make sure this is never something terrible to call unlink on (including making sure the delete_output_files function is *obviously* never called if creating the files didn't succeed). > +/* Main program to convert flat files into built-in initialization code. */ > +int > +main (int argc, const char **argv) > +{ > + if (argc != 6) > + { > + fprintf (stderr, > + "Five arguments required: two input file and three output " > + "files.\n"); Two input file_s_ :-) (Or s/file //). > + pgm_path = argv[0]; This isn't portable (depending on what you use it for -- argv[0] is not necessarily a path at all). > + bif_file = fopen (bif_path, "r"); > + if (!bif_file) > + { > + fprintf (stderr, "Cannot find input built-in file '%s'.\n", bif_path); > + exit (1); > + } Say s/find/open/ in the error? > + fprintf (stderr, "Cannot find input overload file '%s'.\n", ovld_path); (more) Okay with those trivialities, and the unlink stuff looked at. Thanks! Segher