Received: by 10.223.185.116 with SMTP id b49csp3278175wrg; Mon, 12 Feb 2018 23:59:13 -0800 (PST) X-Google-Smtp-Source: AH8x226A37BW+eRJJ+CS7DnTHEZOgzW462CGLzZxXiWr3gXh+R4xBPbq7+8efn4L+jqzwuEX+M3A X-Received: by 10.99.152.70 with SMTP id l6mr304975pgo.87.1518508753871; Mon, 12 Feb 2018 23:59:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518508753; cv=none; d=google.com; s=arc-20160816; b=Ncd/XVBJ3Fha9co6Yh1P8ObhkPfA1/aBvzX8S79dBk2inn06pJj5dpsGg8RL9tVu01 sZnz88FTvptognLLwMSQCTewfZE37wJ8x2tDPOXtxQfAu5UExe1e89V6UoohIV1Nxl+8 mCQK8iXFD7fm4A4cLBrh0OGQFUArVCAP9zuV/iEaU99BGN5Ds/3l8IVQJNNH/YwsYOyn +tUqLhez4FFgZUraWiMQtPWzxeAucZ6hqC1raR0J3jaZ/OiJZoVFDy++Gi/zq2jYGaHV pQnOX7h+CJZHXIKJukVQpBSZ4yNnFTJ+AdpcdW1R+zDPf0gb3YwY1+wK2bXgFXgPlVh/ NY5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=Y05AD6oWBRs3CkJLjjOcJzS92AaMXapG2CsrB2wLFtM=; b=jSz4UwyD7M077l/c9rDORS6ga+80wGlm8N+jvhDXXl41L1aMuAZLTz0oGVodXMWGCw SNPzAz/QeWQhOfR0hK/wsFy9zJhFxf0CQvrpa4sypHg6V9B1zCgMnu7hzA54Q0rnsNPu xTTLHW0MDEToIMcPcmsjrqz/kQRfxPXmTZVH8PsrXEjprd3EnqroXoZEZHr9YV0xDjMb UGXazljyaM9RpaFAFIo4XiK+yX0rGWCnuIX1NurOOk2hMIaexN7N2mj0knuLKkCmTtl0 6ztcPSp1kVoszapnrHTxeLWAgekK7f3Wz9Bu0DuCDQK3Y7DWxTgc+QlteT5DYw1Xr152 dbzQ== 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 h4-v6si7071245pln.91.2018.02.12.23.58.58; Mon, 12 Feb 2018 23:59:13 -0800 (PST) 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 S933641AbeBMH6P convert rfc822-to-8bit (ORCPT + 99 others); Tue, 13 Feb 2018 02:58:15 -0500 Received: from mx01.hxt-semitech.com.96.203.223.in-addr.arpa ([223.203.96.7]:39567 "EHLO barracuda.hxt-semitech.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S933550AbeBMH6O (ORCPT ); Tue, 13 Feb 2018 02:58:14 -0500 X-ASG-Debug-ID: 1518508690-093b7e4b503eeb0001-xx1T2L Received: from HXTBJIDCEMVIW01.hxtcorp.net (localhost [10.128.0.14]) by barracuda.hxt-semitech.com with ESMTP id kHoOQyavKuBvQeEm (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 13 Feb 2018 15:58:10 +0800 (CST) X-Barracuda-Envelope-From: shunyong.yang@hxt-semitech.com Received: from HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) by HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) with Microsoft SMTP Server (TLS) id 15.0.847.32; Tue, 13 Feb 2018 15:58:09 +0800 Received: from HXTBJIDCEMVIW01.hxtcorp.net ([fe80::f451:a443:c0b5:87d1]) by HXTBJIDCEMVIW01.hxtcorp.net ([fe80::f451:a443:c0b5:87d1%12]) with mapi id 15.00.0847.030; Tue, 13 Feb 2018 15:57:51 +0800 From: "Yang, Shunyong" To: "linux@rasmusvillemoes.dk" CC: "linux-kernel@vger.kernel.org" , "andriy.shevchenko@linux.intel.com" , "Zheng, Joey" , "me@tobin.cc" Subject: Re: [PATCH] vsprintf: replace space with readable '=' before crng is ready Thread-Topic: [PATCH] vsprintf: replace space with readable '=' before crng is ready X-ASG-Orig-Subj: Re: [PATCH] vsprintf: replace space with readable '=' before crng is ready Thread-Index: AQHTpJMy03PZ12s5rE2BmcmzlD2+sKOhZgCAgAALbQA= Date: Tue, 13 Feb 2018 07:57:50 +0000 Message-ID: <1518508670.3326.6.camel@hxt-semitech.com> References: <1518502848-7694-1-git-send-email-shunyong.yang@hxt-semitech.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.64.6.28] Content-Type: text/plain; charset="iso-8859-15" Content-ID: <30E61B702F14C94588059CEB4C178DEA@hxt-semitech.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Barracuda-Connect: localhost[10.128.0.14] X-Barracuda-Start-Time: 1518508690 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA X-Barracuda-URL: https://192.168.50.101:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at hxt-semitech.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.4501 1.0000 0.0000 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.47867 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi,?Rasmus, On Tue, 2018-02-13 at 08:16 +0100, Rasmus Villemoes wrote: > On 13 February 2018 at 07:20, Shunyong Yang > wrote: > > > > > > > This patch replaces space with readable "=" when output needs > > padding. > > Following is the output after applying the patch, > > > > Suggested-by: Rasmus Villemoes > > > > ????????if (unlikely(!have_filled_random_ptr_key)) { > > +???????????????char *ptrval_str = "(ptrval)"; > > +???????????????char str[default_width + 1]; > > +???????????????int len = strlen(ptrval_str); > > + > > +???????????????if (default_width > len) { > > +???????????????????????int pos; > > + > > +???????????????????????pos = (default_width - len) / 2; > > +???????????????????????memset(str, '=', default_width); > > +???????????????????????memcpy(str + pos + 1, ptrval_str + 1, len - > > 2); > > +???????????????????????str[0] = '('; > > +???????????????????????str[default_width - 1] = ')'; > > +???????????????????????str[default_width] = 0; > > +???????????????????????ptrval_str = str; > > +???????????????} > > + > I'm sorry, but that's way too convoluted. > > > > > ????????????????spec.field_width = default_width; > > ????????????????/* string length must be less than default_width */ > > -???????????????return string(buf, end, "(ptrval)", spec); > > +???????????????return string(buf, end, ptrval_str, spec); > > ????????} > I was thinking of just doing something like > > -???????????????return string(buf, end, "(ptrval)", spec); > +???????????????return string(buf, end, sizeof(void *) == 8 ? > "(====ptrval====)" : "(ptrval)", spec); > Thanks a lot! It's more straightforward considering 32/64-bit system. Thanks. Shunyong.