Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1884977imm; Thu, 18 Oct 2018 06:00:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV613CNZRc7MAyResTUrHNIuKLTgo0WbQTXsG+ETeVFWdWPmsIf3hT2UWHmG38YVzw20/UqYU X-Received: by 2002:a17:902:6102:: with SMTP id t2-v6mr29029761plj.278.1539867606328; Thu, 18 Oct 2018 06:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539867606; cv=none; d=google.com; s=arc-20160816; b=lUl86tbk5zD1DaHx+kDYR7PJl3hMUmL1VMRG8hTvE0/y9Q0XkgEOWW7T5jaszGIoTl QeFpFJym0WPmaOJgAVB+7PzMt5gTATUYQtLEYIwBCO07QgW+6dnOdQJNmtXVQfUJ1n4v rFJSzRl988SdEbX6P2Ok1xGUybVJHtI7aiUweiH2tYl5g5YbUXG9XXcXuzP69F92J/sF al7zkSBO9F83moURg97xiF8NzPzEBPqsF0QTLDP8VGMEejwOYbrXkyD+Tn5PIGo63Knf ogDqm6sr2re3ZizzDAAm0GOiO4JimwIJuigq7+BemLNalHAeNv3XJ3SLEIlJaQ1NltKa Rl8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=6kZfiRK9WPrpXp9eTIrzw605mgObtcSAaVFnSz6+ClA=; b=TuiBZf67OeoCoVLN8pqQ1iiClP9hIgr68WWKQlG22CuBBetQFo7W+vu86n6UzwxdM5 6l06p9FS0ws1tBwFz8XGgEdGxgvWBgltTU6ukHtCUnbE16chqtxpAQptqQZQMqWbh6p3 hoxGjfwchwO5EIU3NczU6aEmT8tlE1LtRoTOgVJwP70z2rT4OcCKpsMW9b6AhAqosgkQ kUyelPgdHBc3iaWc3/+n4q5haRWiStRo+teVrQELrWP5dlRs/USrR1vOMOJc1fd5r17W fS5ATL7Dl8ssabV6cPywYw3ClyGJw8p65MBF4cRcPDAxDSXu22KA2PtIFLctHGxYyWPl D7LQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3-v6si17895970pld.424.2018.10.18.05.59.50; Thu, 18 Oct 2018 06:00:06 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727235AbeJRU72 (ORCPT + 99 others); Thu, 18 Oct 2018 16:59:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31818 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726325AbeJRU71 (ORCPT ); Thu, 18 Oct 2018 16:59:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81A1474F0B; Thu, 18 Oct 2018 12:58:33 +0000 (UTC) Received: from treble (ovpn-123-182.rdu2.redhat.com [10.10.123.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C80C35FCD1; Thu, 18 Oct 2018 12:58:26 +0000 (UTC) Date: Thu, 18 Oct 2018 07:58:24 -0500 From: Josh Poimboeuf To: Petr Mladek Cc: Jiri Kosina , Miroslav Benes , Jason Baron , Joe Lawrence , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v13 02/12] livepatch: Helper macros to define livepatch structures Message-ID: <20181018125824.ms5zovmsnikv3bgt@treble> References: <20181015123713.25868-1-pmladek@suse.com> <20181015123713.25868-3-pmladek@suse.com> <20181017181756.cy65ujygmf3ulmiz@treble> <20181018111153.qcmvidttifi57u45@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181018111153.qcmvidttifi57u45@pathway.suse.cz> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 18 Oct 2018 12:58:33 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 18, 2018 at 01:11:53PM +0200, Petr Mladek wrote: > On Wed 2018-10-17 13:17:56, Josh Poimboeuf wrote: > > On Mon, Oct 15, 2018 at 02:37:03PM +0200, Petr Mladek wrote: > > > The definition of struct klp_func might be a bit confusing. > > > The original function is defined by name as a string. > > > The new function is defined by name as a function pointer > > > casted to unsigned long. > > > > > > This patch adds helper macros that hide the different types. > > > The functions are defined just by the name. For example: > > > > On one hand, these macros are kind of nice, because they do the function > > pointer casting for the user. > > > > On the other hand, they hide the field names, which hurts readability a > > bit. For example, it would be easy to accidentally assign the wrong > > callback function. > > I am not a big fan of the macros either. > > > > Also, it's unfortunate that these macros are needed in the first place. > > > > What if we just change new_addr (and old_addr) to be 'void *'? Then the > > macros wouldn't be as useful, and we could just get rid of them. > > Hmm, I wonder if any change make sense then. The above proposal might > just exchange one confusion with another one: > > + I would expect that a variable called addr is of the type > unsigned long > > + we would need casting when calling ftrace API > > + .new_addr = function_xxx looks a bit weird and it will > be used many times in all livepatch sources. Fair points. Instead of changing new_func to new_addr, how about we leave it alone, and instead change 'unsigned long old_addr' to 'void *old_func'? That would give us consistent naming internally, while making the external interface more sensible and cast-free. We'd still have to cast when passing to the ftrace API, but IMO it would be worth it. -- Josh