From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AEFFC433E6 for ; Fri, 25 Dec 2020 14:58:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 506AC22515 for ; Fri, 25 Dec 2020 14:58:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727482AbgLYO6P (ORCPT ); Fri, 25 Dec 2020 09:58:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40035 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbgLYO6O (ORCPT ); Fri, 25 Dec 2020 09:58:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608908207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h67Ik1L4EFeN6xNYPE5yqVkOkBhTnSq5wIBHrTpEQ/g=; b=CaUDaf0nMixV6zcTS1qRdbtwiCT3iDcy23VjrpAnXD7CuJImuvYHL94SQsJdZ1RniSrrma I5e/BkKyO8GhBPDOzrMIYSnBSnkBPeTHTRBcuT9aOKyssaf3c/w0EAtzFtla36RbBtKKz6 bS7LhTO5j28K+RdXqJpTQgkB9p6IuDQ= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-251-vfkqCLllPqGDNXmS8GZjrg-1; Fri, 25 Dec 2020 09:56:45 -0500 X-MC-Unique: vfkqCLllPqGDNXmS8GZjrg-1 Received: by mail-ot1-f72.google.com with SMTP id 67so2576369otg.15 for ; Fri, 25 Dec 2020 06:56:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=h67Ik1L4EFeN6xNYPE5yqVkOkBhTnSq5wIBHrTpEQ/g=; b=dUyuJOpMCOs2qUvpCSRFyzjUFGgHx0gm9Zsf/iKxh1S5PFM6zlXYzGarFEvSN7gNqw VTjAXXsKdZQbOL2HNE4zot0cx++2Qeh4wKNgUUrA69yuMF3t9rn26KhDXFRyltPboYH9 TVgx7WIZHnB3jzSWV2iyagChMboEbVJoKczsVUbFlCufQKAzwVs1XAcGGOBkFOxcnG+A WIiYwE/JgocGUQdxuKU585DbExc6TumnDOmpDCy1QT4LkEAf5OaaUf/I73mtUmTAtB6e dQJt6GyCaA74zRsB32NEoTIb2kBIo999PB5f/QM+2/8zUCEtFO7DVYbSVo+3Acqjmlu4 vTKQ== X-Gm-Message-State: AOAM531Edy5iTVzphI0ktH6/Y9hRizbhfl/jpw72BozrcbjBpSRXSBz6 H6Pg+1IekEIPX7G3YlYm03Ds2DVQdovs3MCUwsdmrhIP2TtkYJNijXEjSFrgeX8tHShsjAgezyd jTVHZLpgGrNNqwoe3Mlxdnl8nfGcjNv/sS4pSFfGXAfMIx/mfq9zjghPIplGiviTKgJGfEnU= X-Received: by 2002:a05:6808:148:: with SMTP id h8mr5521666oie.10.1608908204753; Fri, 25 Dec 2020 06:56:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2QlzbWDcBFNn++yW7Xiy4zYIJEj/pqT2gvxb+VW6ALnn1r0RllmCbZ7v3Vh3jzXzhWihxAg== X-Received: by 2002:a05:6808:148:: with SMTP id h8mr5521637oie.10.1608908204539; Fri, 25 Dec 2020 06:56:44 -0800 (PST) Received: from trix.remote.csb (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id j126sm3841502oif.8.2020.12.25.06.56.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Dec 2020 06:56:43 -0800 (PST) Subject: Re: [PATCH] nfp: remove h from printk format specifier To: Joe Perches , Simon Horman Cc: kuba@kernel.org, davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, gustavoars@kernel.org, louis.peens@netronome.com, netdev@vger.kernel.org, bpf@vger.kernel.org, oss-drivers@netronome.com, linux-kernel@vger.kernel.org References: <20201223202053.131157-1-trix@redhat.com> <20201224202152.GA3380@netronome.com> <18c81854639aa21e76c8b26cc3e7999b0428cc4e.camel@perches.com> From: Tom Rix Message-ID: <7b5517e6-41a9-cc7f-f42f-8ef449f3898e@redhat.com> Date: Fri, 25 Dec 2020 06:56:41 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <18c81854639aa21e76c8b26cc3e7999b0428cc4e.camel@perches.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/24/20 2:39 PM, Joe Perches wrote: > On Thu, 2020-12-24 at 14:14 -0800, Tom Rix wrote: >> On 12/24/20 12:21 PM, Simon Horman wrote: >>> On Wed, Dec 23, 2020 at 12:20:53PM -0800, trix@redhat.com wrote: >>>> From: Tom Rix >>>> >>>> This change fixes the checkpatch warning described in this commit >>>> commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]") >>>> >>>> Standard integer promotion is already done and %hx and %hhx is useless >>>> so do not encourage the use of %hh[xudi] or %h[xudi]. >>>> >>>> Signed-off-by: Tom Rix >>> Hi Tom, >>> >>> This patch looks appropriate for net-next, which is currently closed. >>> >>> The changes look fine, but I'm curious to know if its intentionally that >>> the following was left alone in ethernet/netronome/nfp/nfp_net_ethtool.c:nfp_net_get_nspinfo() >>> >>> snprintf(version, ETHTOOL_FWVERS_LEN, "%hu.%hu" >> I am limiting changes to logging functions, what is roughly in checkpatch. >> >> I can add this snprintf in if you want. > I'm a bit confused here Tom. > > I thought your clang-tidy script was looking for anything marked with > __printf() that is using %h[idux] or %hh[idux]. Yes, it uses the format attribute to find the logging functions. > > Wouldn't snprintf qualify for this already? > > include/linux/kernel.h-extern __printf(3, 4) > include/linux/kernel.h:int snprintf(char *buf, size_t size, const char *fmt, ...); Yes, this is found. But since snprintf is not really a logging function, I ignore these. If someone asks for them not to be ignored in a specific change, I will do that. > > Kernel code doesn't use a signed char or short with %hx or %hu very often > but in case you didn't already know, any signed char/short emitted with > anything like %hx or %hu needs to be left alone as sign extension occurs so: Yes, this would also effect checkpatch. Tom > > signed char foo = -1; > printk("%hx", foo); > > emits ffff but > > printk("%x", foo); > > emits ffffffff > > An example: > > $ gcc -x c - > #include > #include > > int main(int argc, char **argv) > { > signed short i = -1; > printf("hx: %hx\n", i); > printf("x: %x\n", i); > printf("hu: %hu\n", i); > printf("u: %u\n", i); > return 0; > } > > $ ./a.out > hx: ffff > x: ffffffff > hu: 65535 > u: 4294967295 > > $ > >