Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10152790imu; Sun, 30 Dec 2018 14:14:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/WWdrExokr4mQGzahCep3kB6q8g3mCMWVV//FaQGHwDdoZ9Pu6hDl86bpkASmuBH1J8kKCt X-Received: by 2002:a62:3006:: with SMTP id w6mr36391815pfw.258.1546208077634; Sun, 30 Dec 2018 14:14:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546208077; cv=none; d=google.com; s=arc-20160816; b=ss5xQ+bbfTRBCU3peiWwEhrTZCpBD/6+LOIsm8780Wr9cyhj8wj3UZesjLS+knr9QP pcLq9ujettvNBT+KL1D6/S5lxnx29KbWEdg3s6cP2Yfj08UsugDZ9wo8FI9zMccAxEHZ SC2jpNvPm+w+9iHfvJ6mjVNY6ZfryFgpMaAU1r3y4xSmkPED8S82rPzwhA1nxP2uFMZe 7iW1ZUED6oVx1mbnrrs0U7Ytv9d6lg7UZd8h/Z3FyEvNyWWkxEjY0XDsLw4dHdduUf0v YMsjCHhFseUEkNcOHUwdy9IpkuyjqDgzI1OcK/nUV/KasZeIwENTXNqg1CeQ7gjkwIGJ 4AFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:message-id :in-reply-to:subject:cc:to:from:date; bh=Q7M1Ujq+QMqr6d7VamuVYgrpsTqxpzXYGodzRgcBfko=; b=HsNpxmPBVLf2LfflFWPN6cuJ4uZiKiCp8FV5k/yeMrPz1pQxq7XKMPuf3EbnHEbbm3 /RPWh8LTDzjeAJ6Kg0iRH5K4RrfGknNajY+kqOnlTpuHFdMRcVH4qMvP2GULtsRiYdTq 68H7WB28kxyqnZwWIf48nlqPPCtPf4GAIPigBK5TleX3xgqb6jC+p7mYuZSeeXCAtwYD ePiurRXODzUIzqcEwqzxrrCMaKEPhSFca8fSrODzcLjmLaDOoT/JG+Vly8f5x5C4klFo zg8iXU/QdFl2E6o9zOYL4mODqHY/XA0ryYAVNZsIBf1nXXZvBYQNMlZKRGewTHIWOP2S 6CYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y13si42038085pgj.157.2018.12.30.14.14.09; Sun, 30 Dec 2018 14:14:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726839AbeL3WMt (ORCPT + 99 others); Sun, 30 Dec 2018 17:12:49 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:33944 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726489AbeL3WMt (ORCPT ); Sun, 30 Dec 2018 17:12:49 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id 5AD0629BC9; Sun, 30 Dec 2018 17:12:44 -0500 (EST) Date: Mon, 31 Dec 2018 09:12:42 +1100 (AEDT) From: Finn Thain To: LEROY Christophe cc: Joshua Thompson , linuxppc-dev , Geert Uytterhoeven , linux-m68k , Linux Kernel Mailing List , Greg Kroah-Hartman , Arnd Bergmann Subject: Re: [PATCH v8 13/25] m68k: Dispatch nvram_ops calls to Atari or Mac functions In-Reply-To: <20181230185300.Horde.o5iU5x8n8UeDsyjemaBU_w7@messagerie.si.c-s.fr> Message-ID: References: <505240b144f1666acf26a3c1e93c8e6868fe1408.1545784679.git.fthain@telegraphics.com.au> <20181230185300.Horde.o5iU5x8n8UeDsyjemaBU_w7@messagerie.si.c-s.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 30 Dec 2018, LEROY Christophe wrote: > > > > > > Since the operations are almost entirely distinct, why not have two > > > separate 'nvram_ops' instances here that each refer to just the set > > > they actually need? > > > > > > > The reason for that is that I am alergic to code duplication. But I'll > > change it if you think it matters. BTW, this patch has already been > > acked by Geert. > > I agree it would be cleaner, as it would also avoid this > m68k_nvram_get_size() wouldn't it ? > No, that function makes run-time decisions. #ifdef won't work. > I don't see potential code duplication here, do you ? > Here's my problem with Arnd's suggestion. Consider this C code, #ifdef FOO const struct nvram_ops arch_nvram_ops = { /* ... */ } #else const struct nvram_ops arch_nvram_ops = { /* ... */ } #endif Lets say you write a hypothetical patch to remove the 'const'. Now you have two 'const' keywords to edit, and you have the risk of overlooking one of them. The solution to this problem is sometimes referred to as "DRY", meaning Don't Repeat Yourself: const struct nvram_ops arch_nvram_ops = { /* ... */ #ifdef FOO /* ... */ #else /* ... */ #endif /* ... */ } But I'm over-simplifying. Arnd's alternative actually goes like this, #if defined(CONFIG_MAC) && !defined(CONFIG_ATARI) const struct nvram_ops arch_nvram_ops = { /* ... */ } #elif !defined(CONFIG_MAC) && defined(CONFIG_ATARI) const struct nvram_ops arch_nvram_ops = { /* ... */ } #elif defined(CONFIG_MAC) && defined(CONFIG_ATARI) const struct nvram_ops arch_nvram_ops = { /* ... */ } #endif So, you're right, this isn't "duplication", it's "triplication". -- > Christophe >