Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp618338imm; Wed, 19 Sep 2018 04:21:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaUTiSszlkNCupltIczl3GeFWI9c68CIaRx+yyEOaC2AENEg+5tTGGkH+frV4zu8Dtw0KxL X-Received: by 2002:a17:902:ab94:: with SMTP id f20-v6mr34429139plr.231.1537356084924; Wed, 19 Sep 2018 04:21:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537356084; cv=none; d=google.com; s=arc-20160816; b=F2VWWWflH988kQYsl441ePxNE6i8UTS13aOmBdBfo3HmACICoBSZlN3cizDL3CIg/x nEnENmrNQcZtaC8j25/8LMCa4YKTdMOIHe5CiIKafVvzMIxTHdwzBiBrtskg1YNQkt7A f/vOYHl/FVCiV9m3ULIp4sPutQYGFMv/xWt/HIat6G+PI+KZz5alo1GRO/V6gxL0f7ll L9ED6FrvCLfXhbxH61dFlX7TpXEEUkiNZilnRC/1vmwUe54fVoMZMMXKu8yurJWW1ZeJ eBBiJB4G+oX1ElIwrHWZaR6Tb7q7LLJUGysCGXgvOvjW0gpuHZZfOP9AnNlmsonozbMB k2Sg== 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=RAv7dsAEFwiVmv0aLJ7b/80glIIPl0cGq76ktxFNdKE=; b=vFtu27NvEy0T77NywFRCqcKgUhEqnm4xLN0rPiIyoM16/LbhehH3I1YPk3jhnUv3Ii Dkb+H+SvBy8YkpoOAnXsclykwj6hWfLxyuMoNSSFDUSAiytCSk/+zFEvKucFiUjHcQV2 N4r+J4Zm5TFFxmv543OG/7s1zhQGioQt7FIuvY2qvp431JcnYsAXxcjmSkrUmXRpRPtT GIP4y1KfYnTundxw/tsEICTF40dabPkDL3LJM8Rb7BjlfewCHF4l/blavZiU4mBUisd7 JJXbVJZ24XgGpvRWaoUAG71DpgNhURziZg88RUPK1HjNxL+HzYuhG/L9Z4bbDzwZcMEk HXfQ== 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 d20-v6si21032351pgj.535.2018.09.19.04.21.09; Wed, 19 Sep 2018 04:21:24 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731444AbeISQ5s (ORCPT + 99 others); Wed, 19 Sep 2018 12:57:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:52306 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727948AbeISQ5r (ORCPT ); Wed, 19 Sep 2018 12:57:47 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A030DB032; Wed, 19 Sep 2018 11:20:19 +0000 (UTC) Date: Wed, 19 Sep 2018 13:20:18 +0200 From: Petr Mladek To: Sergey Senozhatsky Cc: zhe.he@windriver.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] printk: Add KBUILD_MODNAME and correct bare use of unsigned Message-ID: <20180919112018.fvncsxc7goffdhpo@pathway.suse.cz> References: <1537291068-443145-1-git-send-email-zhe.he@windriver.com> <1537291068-443145-2-git-send-email-zhe.he@windriver.com> <20180919020621.GA390@jagdpanzerIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180919020621.GA390@jagdpanzerIV> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2018-09-19 11:06:21, Sergey Senozhatsky wrote: > On (09/19/18 01:17), zhe.he@windriver.com wrote: > > Add KBUILD_MODNAME to make prints more clear. > > No strong opinion. I'm OK with this change. > > > And use 'unsigned int' intead of 'unsigned' according to > > checkpatch.pl's suggestion. > > I don't think that "unsigned int" is the right thing to use there. > > > if (console_seq < log_first_seq) { > > len = sprintf(text, "** %u printk messages dropped **\n", > > - (unsigned)(log_first_seq - console_seq)); > > + (unsigned int)(log_first_seq - console_seq)); > > Both log_first_seq and console_seq are u64. > > log_first_seq - console_seq > > thus, *in theory*, can be larger than "unsigned int". So I'd just avoid cast > and use an appropriate for u64 %llu sprintf() specifier. Something like below, > perhaps: > > --- > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index f73ea9dd6f46..4b8c5832bf14 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -2408,8 +2408,9 @@ void console_unlock(void) > printk_safe_enter_irqsave(flags); > raw_spin_lock(&logbuf_lock); > if (console_seq < log_first_seq) { > - len = sprintf(text, "** %u printk messages dropped **\n", > - (unsigned int)(log_first_seq - console_seq)); > + len = sprintf(text, > + "** %llu printk messages dropped **\n", > + log_first_seq - console_seq); This looks like a better solution. Also please, define pr_fmt and fix the casting in separate patches. Best Regards, Petr