From patchwork Tue Sep 3 12:55:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chung-Lin Tang X-Patchwork-Id: 34376 Received: (qmail 100181 invoked by alias); 3 Sep 2019 12:55:23 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 100168 invoked by uid 89); 3 Sep 2019 12:55:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*UA:Intel, H*u:Intel, H*UA:Macintosh, H*u:Macintosh X-HELO: esa4.mentor.iphmx.com IronPort-SDR: 6iu16jlw+jrjeVsM8Y2QQG7n2KgydXt29aE7CXe6fLef6+sMAdkbwTItQaA8N8KfJjthp3vXKm M09qje96oQm8yMzKhnQEBf4JyrEeAhd1I9vzDhr3y7uUhLqAxgYrN5P3dXLob+r7e+Pz+mecG2 JlxSdgxyMAV3HqC7vxXrFm8WVAJKElz8tlL6MVK9ct971TeJYnVWg6JvrnxfStm+5wddL6NmF2 BgWj7ZRHvWthKbpoCKJ4tRRwCYGADjFYTxFnKteewEo7BRNiat3yaYfm+QTEfxvK1TGPss3VaF MxI= IronPort-SDR: lZMkRrYb2F71rvwM/jaTaN8aBxuurpKv7VDog2WJYjN7wICX2i/vHlkA48bF2duui2+qsoddaR XxePX60t/ZZAbAhZBMhlqi6x+HK5wRIk3p69+9mX/j3KQoiZ2wm5nPdky8fZcFlf6ssmfyxRtS prkNBA1vTnDZVSN9TT9EY5kgLo2HWG72TxUYEUefKmFu+TYNC/H6F3kV3j9YlFFCq0r/GtZBr+ xLodGWYb0gHTwyeFJp1i3BKny8nYV4sRHUBjn5lBU8hdiwE0bmRiMQArHC+CuZcm/W7+pfT9vU XaY= Reply-To: From: Chung-Lin Tang Subject: [PATCH] Small fix to HP timing printing To: GNU C Library Message-ID: Date: Tue, 3 Sep 2019 20:55:12 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 Return-Path: chunglin_tang@mentor.com Hi, when developing my dynamic linker DSO sorting patch [1], and measuring its cycle performance, I found a small error in the HP_TIMING_PRINT trailing zero setting; the '\0' should be set at MIN(Len,string length), instead of always at the 'Len' position. Encountered some weirdness in printing counter results because of this. Okay for master? [1] https://sourceware.org/ml/libc-alpha/2019-07/msg00472.html https://sourceware.org/ml/libc-alpha/2019-07/msg00473.html Thanks, Chung-Lin * sysdeps/generic/hp-timing-common.h (HP_TIMING_PRINT): Correct position of string null termination. Reviewed-by: Adhemerval Zanella diff --git a/sysdeps/generic/hp-timing-common.h b/sysdeps/generic/hp-timing-common.h index 8749d25647..1fc92d1bd7 100644 --- a/sysdeps/generic/hp-timing-common.h +++ b/sysdeps/generic/hp-timing-common.h @@ -56,5 +56,5 @@ char *__cp = _itoa ((Val), __buf + sizeof (__buf), 10, 0); \ size_t __cp_len = MIN (__buf + sizeof (__buf) - __cp, __len); \ memcpy (__dest, __cp, __cp_len); \ - __dest[__len - 1] = '\0'; \ + __dest[__cp_len - 1] = '\0'; \ } while (0)