From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.3 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 8C6FA202A5 for ; Wed, 20 Sep 2017 21:52:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751547AbdITVv6 (ORCPT ); Wed, 20 Sep 2017 17:51:58 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:34629 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751408AbdITVv5 (ORCPT ); Wed, 20 Sep 2017 17:51:57 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3xyD3Z4F5Pz1s23j; Wed, 20 Sep 2017 23:51:54 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 3xyD3Z3BDrz1r0x4; Wed, 20 Sep 2017 23:51:54 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id xQD79-UN2-XW; Wed, 20 Sep 2017 23:51:53 +0200 (CEST) X-Auth-Info: 5D9e0/BddxfUT6DDTtDi7MApUMbulZq8QhtO3zMh2RcdNiH8FscJg3MqzIgnDDpb Received: from igel.home (ppp-88-217-17-201.dynamic.mnet-online.de [88.217.17.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Wed, 20 Sep 2017 23:51:53 +0200 (CEST) Received: by igel.home (Postfix, from userid 1000) id 31A8D2C3975; Wed, 20 Sep 2017 23:51:53 +0200 (CEST) From: Andreas Schwab To: Jonathan Nieder Cc: Junio C Hamano , Kaartic Sivaraam , Michael Haggerty , Alex Riesen , git@vger.kernel.org Subject: Re: [PATCH v2] for_each_string_list_item: avoid undefined behavior for empty list References: <20170915184323.GU27425@aiede.mtv.corp.google.com> <20170920023008.GB126984@aiede.mtv.corp.google.com> <20170920052705.GC126984@aiede.mtv.corp.google.com> <87vakd2v22.fsf@linux-m68k.org> <20170920173134.GZ27425@aiede.mtv.corp.google.com> X-Yow: I'm a GENIUS! I want to dispute sentence structure with SUSAN SONTAG!! Date: Wed, 20 Sep 2017 23:51:53 +0200 In-Reply-To: <20170920173134.GZ27425@aiede.mtv.corp.google.com> (Jonathan Nieder's message of "Wed, 20 Sep 2017 10:31:34 -0700") Message-ID: <87lgl9rqbq.fsf@linux-m68k.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Sep 20 2017, Jonathan Nieder wrote: > Andreas Schwab wrote: >> On Sep 19 2017, Jonathan Nieder wrote: > >>> B. #define for_each_string_list_item(item, list) \ >>> if (list->items) \ >>> for (item = ...; ...; ... ) >>> >>> This breaks a caller like >>> if (foo) >>> for_each_string_list_item(item, list) >>> ... >>> else >>> ... >>> >>> making it a non-starter. >> >> That can be fixed with a dangling else. > > I believe the fix you're referring to is option C, from the same email > you are replying to. If not, please correct me. A variant thereof, yes. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."