Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5192023ybp; Mon, 14 Oct 2019 17:19:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUOIBtLSFTaEPQL33efTkoDsF/OHKzDMjFCGAGiipHpw/FV0xo6j3DSEEMxYk2q2JOht14 X-Received: by 2002:a17:906:95cc:: with SMTP id n12mr31447313ejy.111.1571098749770; Mon, 14 Oct 2019 17:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571098749; cv=none; d=google.com; s=arc-20160816; b=EJTX8pMZ9BV8EDURlUPKM4MUl6xMOSRrcAYv1juod6DgNpCDjtxcHwXdVf9ciy3a2w JC+bBteyN290Xg1gtYEzJXKY9Vd73GW3GBtCxV0FggnSjgXT9NnK+Xlnozsnt9ipHirD ouMbvfahliLhEh25II/BfAKqMm1Z9NTE8e5Gz7x+zzP3CmaQDjvk3003yegwUe8rtMRf 2n0pxil8BZKLYz7iRkJjJ5MZADp3D9a8EvQpAvrIiHiNwdks5K0w/JGAwrIPfyaIMDNf yEEqdaH2plf3MBK10jHzCuL43C9JYT7afdtvGlM9I6fTwJSSEfzQcXw5p1C6eGGop8x2 XBjg== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=S01INIyV+fklkeKDjyJw8HpiViode75kudgiuVlNQho=; b=ccP1kBrpY8CBzw4rCc6RHo94C/QSVcHqC7oKJ/LXwzFRhWb2eVghgZkL768WI2Yaw3 gL17cD5aVViN1sQ9pqSfnx4lC7sofm74ibxBN2gb3ET0FfVthrFwKJw/Sy7Fi0x2nVZ9 9OGsxOoEP+qVyZ9bgM7g9ut7ZU0XuxBsWAo+3c9ug9e1mN/rvqHOJbaPmUjBms+uznIC Ye0OW1jXsiu5yzF3RUiCACOygofCLGdHPRszovD6OlhVAOvKT7JJuW1GCqXNBgJWlw94 /mCK6dFVUCVEgXsQ/6tsSzoqWZB3BdDMLLDaI5vtxyGkvdsFsF/06Ch1cThPjExxTEkn rhkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GaZ52buO; 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 57si14873568edz.280.2019.10.14.17.18.46; Mon, 14 Oct 2019 17:19:09 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GaZ52buO; 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 S1730746AbfJNT5c (ORCPT + 99 others); Mon, 14 Oct 2019 15:57:32 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:35599 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbfJNT5c (ORCPT ); Mon, 14 Oct 2019 15:57:32 -0400 Received: by mail-oi1-f194.google.com with SMTP id x3so14795825oig.2 for ; Mon, 14 Oct 2019 12:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:reply-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=S01INIyV+fklkeKDjyJw8HpiViode75kudgiuVlNQho=; b=GaZ52buO0OTwi5HR740F/BoLVwdE74ahz0/3cNcywM9XNFnxec7OMXPmDsTphcpoPv iyI3apF1YoggNbv+eYVxtVVjgD4cKmyjmNT3ESAIKD5SrT6NeVeXcGUJZy6DbWaFCb77 1EP2Ylo4qA+ZraO7/Qch347HPhNcYbaad69ue6EMeRgux1XGUWI6eIReccXR3pMO9j84 J8EM1orKRUvXOIKA/yFhrsyu1gWcJdWldjoyLH3vr3oi0h1eHm3SHmOvspRgcMOs1ksK rreTm6oXw6b7d/o7tNA/cVC3hxBiVet37Jero9E7SHp09fHPsu+2ShvLbZwtvn0tPybL Zi+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :reply-to:references:mime-version:content-disposition:in-reply-to :user-agent; bh=S01INIyV+fklkeKDjyJw8HpiViode75kudgiuVlNQho=; b=abJaZmi6YxM0k/WBHBvVSxxoszXKwyp6RqNI2z1/hL4YQ2p3MZMIP6f6uXK9MWOYZu 9Ym0++a0H7sd4/DrDcfF1nXJb/rbUWaGweCCaP/NN8m4eB/dgdNhd86qdW1ONqpKSZkD nVnv845OtUoiuz0mvJhjcvdWzKUqy4zdMFHVXdCA+PblQXWakEEtpM8qdiI/DAOOU5dK rZlwUW28bwcX8/pHQ0XxWquhFYRahAY740Si2NXbc2J+reoRIahH7tmreIGW23SchHTW 1JpjlMC5uGZ4/6BXndU62kj3YXDGSFI3auCYcNBDOBZ9eGRC7orBzSwiP3AfDXY1SwPK khpg== X-Gm-Message-State: APjAAAWCBb0+27RXVHrifxUaQWfpBMImVgjdm3FQJ0p/MT/axCSN3TDm SnUbfSiTPpw+eUFnWr6ruQ== X-Received: by 2002:aca:3001:: with SMTP id w1mr8792629oiw.162.1571083051520; Mon, 14 Oct 2019 12:57:31 -0700 (PDT) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id x140sm5965108oix.42.2019.10.14.12.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 12:57:30 -0700 (PDT) Received: from t560 (unknown [192.168.27.180]) by serve.minyard.net (Postfix) with ESMTPSA id 3A0C7180046; Mon, 14 Oct 2019 19:57:30 +0000 (UTC) Date: Mon, 14 Oct 2019 14:57:28 -0500 From: Corey Minyard To: Andy Shevchenko Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Joe Perches , Andy Shevchenko Subject: Re: [PATCH v2] ipmi: use %*ph to print small buffer Message-ID: <20191014195728.GG25427@t560> Reply-To: minyard@acm.org References: <20191011155036.36748-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191011155036.36748-1-andriy.shevchenko@linux.intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 11, 2019 at 06:50:36PM +0300, Andy Shevchenko wrote: > From: Andy Shevchenko > > Use %*ph format to print small buffer as hex string. > > The change is safe since the specifier can handle up to 64 bytes and taking > into account the buffer size of 100 bytes on stack the function has never been > used to dump more than 32 bytes. Note, this also avoids potential buffer > overflow if the length of the input buffer is bigger. This is an improvment, thanks, it is in queue in the next tree and queued for the next merge window. Thanks, Andy and Jes, for sorting this out while I was on vacation, -corey > > This completely eliminates ipmi_debug_msg() in favour of Dynamic Debug. > > Signed-off-by: Andy Shevchenko > Signed-off-by: Andy Shevchenko > --- > - eliminate ipmi_debug_msg() in favour of Dynamic Debug (Joe) > drivers/char/ipmi/ipmi_msghandler.c | 27 ++++----------------------- > 1 file changed, 4 insertions(+), 23 deletions(-) > > diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c > index 2aab80e19ae0..1768b81aaf78 100644 > --- a/drivers/char/ipmi/ipmi_msghandler.c > +++ b/drivers/char/ipmi/ipmi_msghandler.c > @@ -44,25 +44,6 @@ static void need_waiter(struct ipmi_smi *intf); > static int handle_one_recv_msg(struct ipmi_smi *intf, > struct ipmi_smi_msg *msg); > > -#ifdef DEBUG > -static void ipmi_debug_msg(const char *title, unsigned char *data, > - unsigned int len) > -{ > - int i, pos; > - char buf[100]; > - > - pos = snprintf(buf, sizeof(buf), "%s: ", title); > - for (i = 0; i < len; i++) > - pos += snprintf(buf + pos, sizeof(buf) - pos, > - " %2.2x", data[i]); > - pr_debug("%s\n", buf); > -} > -#else > -static void ipmi_debug_msg(const char *title, unsigned char *data, > - unsigned int len) > -{ } > -#endif > - > static bool initialized; > static bool drvregistered; > > @@ -2267,7 +2248,7 @@ static int i_ipmi_request(struct ipmi_user *user, > ipmi_free_smi_msg(smi_msg); > ipmi_free_recv_msg(recv_msg); > } else { > - ipmi_debug_msg("Send", smi_msg->data, smi_msg->data_size); > + pr_debug("Send: %*ph\n", smi_msg->data_size, smi_msg->data); > > smi_send(intf, intf->handlers, smi_msg, priority); > } > @@ -3730,7 +3711,7 @@ static int handle_ipmb_get_msg_cmd(struct ipmi_smi *intf, > msg->data[10] = ipmb_checksum(&msg->data[6], 4); > msg->data_size = 11; > > - ipmi_debug_msg("Invalid command:", msg->data, msg->data_size); > + pr_debug("Invalid command: %*ph\n", msg->data_size, msg->data); > > rcu_read_lock(); > if (!intf->in_shutdown) { > @@ -4217,7 +4198,7 @@ static int handle_one_recv_msg(struct ipmi_smi *intf, > int requeue; > int chan; > > - ipmi_debug_msg("Recv:", msg->rsp, msg->rsp_size); > + pr_debug("Recv: %*ph\n", msg->rsp_size, msg->rsp); > > if ((msg->data_size >= 2) > && (msg->data[0] == (IPMI_NETFN_APP_REQUEST << 2)) > @@ -4576,7 +4557,7 @@ smi_from_recv_msg(struct ipmi_smi *intf, struct ipmi_recv_msg *recv_msg, > smi_msg->data_size = recv_msg->msg.data_len; > smi_msg->msgid = STORE_SEQ_IN_MSGID(seq, seqid); > > - ipmi_debug_msg("Resend: ", smi_msg->data, smi_msg->data_size); > + pr_debug("Resend: %*ph\n", smi_msg->data_size, smi_msg->data); > > return smi_msg; > } > -- > 2.23.0 >