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=-8.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, UNPARSEABLE_RELAY autolearn=ham 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 EEA52C4707F for ; Thu, 27 May 2021 20:23:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBC5561360 for ; Thu, 27 May 2021 20:23:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236544AbhE0UZP (ORCPT ); Thu, 27 May 2021 16:25:15 -0400 Received: from smtprelay0025.hostedemail.com ([216.40.44.25]:45658 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235808AbhE0UZH (ORCPT ); Thu, 27 May 2021 16:25:07 -0400 Received: from omf04.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id 0C676180A55F9; Thu, 27 May 2021 20:23:33 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf04.hostedemail.com (Postfix) with ESMTPA id B9DE4D1516; Thu, 27 May 2021 20:23:30 +0000 (UTC) Message-ID: Subject: Re: [PATCH v5 2/5] PCI/sysfs: Use return value from dsm_label_utf16s_to_utf8s() directly From: Joe Perches To: Krzysztof =?UTF-8?Q?Wilczy=C5=84ski?= , Bjorn Helgaas Cc: Logan Gunthorpe , Oliver O'Halloran , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Tyrel Datwyler , Russell Currey , Kurt Schwemmer , Vidya Sagar , Xiongfeng Wang , linux-pci@vger.kernel.org Date: Thu, 27 May 2021 13:23:29 -0700 In-Reply-To: <20210527201650.221944-2-kw@linux.com> References: <20210527201650.221944-1-kw@linux.com> <20210527201650.221944-2-kw@linux.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspamout05 X-Rspamd-Queue-Id: B9DE4D1516 X-Stat-Signature: gzcomztjwrahh9m8xbyr99tej9jqq4e3 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+KZGQWYSjdwbFqSkWdoUgNyJGFrAYE+8o= X-HE-Tag: 1622147010-31965 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Thu, 2021-05-27 at 20:16 +0000, Krzysztof Wilczyński wrote: > Modify the function dsm_label_utf16s_to_utf8s() to directly return the > number of bytes written into the buffer so that the strlen() used later > to calculate the length of the buffer can be removed as it would no > longer be needed. [] > diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c [] > @@ -139,14 +139,17 @@ enum acpi_attr_enum { >   ACPI_ATTR_INDEX_SHOW, >  }; >   > > -static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf) > +static int dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf) >  { >   int len; > + >   len = utf16s_to_utf8s((const wchar_t *)obj->buffer.pointer, >   obj->buffer.length, >   UTF16_LITTLE_ENDIAN, >   buf, PAGE_SIZE); This should be PAGE_SIZE - 1 no? >   buf[len] = '\n'; > + > + return len; return len + 1 ?