Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp396979imm; Wed, 29 Aug 2018 02:51:02 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYjb8EhpU0/4w4/mEdgphNMmrOEKETYPmu1Oee2rRBSBHnOStNko+JC39w7EkvxhJypC7YA X-Received: by 2002:a63:9dcd:: with SMTP id i196-v6mr5085129pgd.238.1535536262297; Wed, 29 Aug 2018 02:51:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535536262; cv=none; d=google.com; s=arc-20160816; b=viTnev8DF+w3PTtrqzusbLfUvcLOK3qFFCr0/1LkSaMi5y7Auqw4J6Ye/J4iNrDLUb a4gDYkQIiCdMAb6x31Cxg8mPzKYZciDO87nOACGhgYWc7VFeGz6jjGbc+luOneR5K44P PQdlcEPg9ZA+6BJ+tK7BG+bwUqNdGlT3eKkj7F5+wTXMBrYzUOUxdj+GUfIq+WyPeyND zpCBdc28sPalzE5P2jaYVqXmx74G3LrMoaEusqAqz2lKMwITSLwwc+HzGnqvvBMWEweh 3k8Cf/WY8T4BdQRbSlarixrdGz72cDJf8PU/m1IdS75oC6/3eUiDb2XuyLshGBFmS9Lw RSCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=wXLo70pKWjlof6E6Nl0rtt/I3lllmCq0jtBBXOYZPuY=; b=KAicL5Bx6Bqj3pCAltcHhXqyMDV7Q5mGDxGXHV+dWZJHrRkNZesrm4b42PXhkBaEMr ayJqbwYPLnqwizrRjjHA/jEdae3McUo31IazFPQ4Ib8QJatvftpx3nnSrWb1LrIzmXFV ukO9OhbhZ3ijT0DOSYt82HFk/Q1mOrs6lmb+UQJbWk5Ztsmo8aKoMhSs/z4KZSoFYVdx tOWHrsymd6or7QUeca9qeDnewJIHVMT5QvGyrHCylyTOgOEXU/Wwj4RUwXxxNN1HB0mA P3BGYBhynRCJtaDMby9COO6dIv5OCx4nQbPutcrBoe2AZ+cNoDPiNr44OKNxTrniezZe U28g== 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 u19-v6si3465575pgl.94.2018.08.29.02.50.47; Wed, 29 Aug 2018 02:51:02 -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 S1728030AbeH2NpT convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Aug 2018 09:45:19 -0400 Received: from eu-smtp-delivery-211.mimecast.com ([146.101.78.211]:24323 "EHLO eu-smtp-delivery-211.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727099AbeH2NpS (ORCPT ); Wed, 29 Aug 2018 09:45:18 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-175-YWswC5VRM12jMnmKf5s2Jg-1; Wed, 29 Aug 2018 10:49:11 +0100 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b::d117) by AcuMS.aculab.com (fd9f:af1c:a25b::d117) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 29 Aug 2018 10:50:50 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Wed, 29 Aug 2018 10:50:50 +0100 From: David Laight To: 'Alexey Dobriyan' , "akpm@linux-foundation.org" CC: "linux-kernel@vger.kernel.org" Subject: RE: [PATCH 06/13] proc: convert /proc/self to _print_integer() Thread-Topic: [PATCH 06/13] proc: convert /proc/self to _print_integer() Thread-Index: AQHUPlw0h/REFtLLZEK6DODn8qrvQaTWfgDA Date: Wed, 29 Aug 2018 09:50:50 +0000 Message-ID: <54cb86c6d96b47bc8017a69be124c105@AcuMS.aculab.com> References: <20180827231503.26899-1-adobriyan@gmail.com> <20180827231503.26899-6-adobriyan@gmail.com> In-Reply-To: <20180827231503.26899-6-adobriyan@gmail.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.33] MIME-Version: 1.0 X-MC-Unique: YWswC5VRM12jMnmKf5s2Jg-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexey Dobriyan > Sent: 28 August 2018 00:15 > --- > fs/proc/self.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/fs/proc/self.c b/fs/proc/self.c > index 127265e5c55f..b2279412237b 100644 > --- a/fs/proc/self.c > +++ b/fs/proc/self.c > @@ -14,6 +14,7 @@ static const char *proc_self_get_link(struct dentry *dentry, > { > struct pid_namespace *ns = proc_pid_ns(inode); > pid_t tgid = task_tgid_nr_ns(current, ns); > + char buf[10], *p = buf + sizeof(buf); > char *name; > > if (!tgid) > @@ -22,7 +23,11 @@ static const char *proc_self_get_link(struct dentry *dentry, > name = kmalloc(10 + 1, dentry ? GFP_KERNEL : GFP_ATOMIC); > if (unlikely(!name)) > return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD); > - sprintf(name, "%u", tgid); > + Best not to 'hide' the initialisation of 'p' at the top of the function. Much easier to see what is going on if it is moved here. > + p = _print_integer_u32(p, tgid); or just: p = _print_integer(buf + sizeof(buf), tgid); (What a horrid interface ...) > + memcpy(name, p, buf + sizeof(buf) - p); > + name[buf + sizeof(buf) - p] = '\0'; > + > set_delayed_call(done, kfree_link, name); > return name; > } > -- > 2.16.4 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)