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=-7.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 79C37C433C1 for ; Wed, 24 Mar 2021 14:15:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48C1461992 for ; Wed, 24 Mar 2021 14:15:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235997AbhCXOPJ (ORCPT ); Wed, 24 Mar 2021 10:15:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235721AbhCXOOk (ORCPT ); Wed, 24 Mar 2021 10:14:40 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D713BC061763 for ; Wed, 24 Mar 2021 07:14:39 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id u9so33122150ejj.7 for ; Wed, 24 Mar 2021 07:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=FCHZXs+Na6H0beDmf/OCng/T5K6DKQZL7k9xPgulymE=; b=CSmURK4SwSnVaLiGIPpo0hW0XaafR3WnY0Kktfn6Q8w2WAkQ2pI/vtZsaqDMr+Rrqm 3j9+izYQ4UqWXHMKZToSCUpFRjOnIXY8UJy2FWXpJpqMTZ1LwLqfqxHXjI3T7WuIhnJ3 rDX0OvQ/BcN4cPnIJD1S57p05tgOJZ1lraw5U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FCHZXs+Na6H0beDmf/OCng/T5K6DKQZL7k9xPgulymE=; b=M/LyLcQVNmSOiidj+ksqL/uTWnyOZu0LXHcFS/roseiW4GBM5nM2VbJMaGz5SPH0Uu kHUPYbunByb0sedWFvTqr0a45LZ1V++eRZgtxUkY9FmrKxwoLqen7obB3K0Vw/82x4KZ 20Lj8nWIfD4MGw4q+vLnyCp4LyKvNfdNEGNQ8BsBqScMKvgLcDngX/qpiiiVl/l+8LQ0 5wESWX/7gn2QNlP+PBANwpb+xOOcUzvCK2U4yJ8wqrzlwKLxoqrdxWtl8XFbhE5B3bKN TADP0kMVLSBTaZv6ZWNiQnxM9PcXmNN2z8EUNgSVQCiNcDb+WdngJX7Km6lOwelndH8s mmWQ== X-Gm-Message-State: AOAM533Fm+I1HYOweZrt2LnC2vqMInpoJN5omPna+w8g3V09iNqmxel5 9pEVzjASsT2CNpqzTd2vuIkxy2rrkz+ybA3s X-Google-Smtp-Source: ABdhPJww1pdM64UL62x05vVdAART6xCBNzDfZeqUIHi/5inBRmV8dfVIuzHdABjEJtiJD1nhk3/fww== X-Received: by 2002:a17:906:8447:: with SMTP id e7mr3979848ejy.523.1616595278353; Wed, 24 Mar 2021 07:14:38 -0700 (PDT) Received: from [192.168.1.149] ([80.208.71.248]) by smtp.gmail.com with ESMTPSA id c10sm1179885edt.64.2021.03.24.07.14.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Mar 2021 07:14:37 -0700 (PDT) Subject: Re: [PATCH] amdgpu: fix gcc -Wrestrict warning To: Arnd Bergmann Cc: Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , David Airlie , Daniel Vetter , Huang Rui , Jinzhou Su , amd-gfx list , dri-devel , Linux Kernel Mailing List References: <20210323130430.2250052-1-arnd@kernel.org> From: Rasmus Villemoes Message-ID: <4e63dbbc-0aa3-2950-dda1-1e6aa19d7d5d@rasmusvillemoes.dk> Date: Wed, 24 Mar 2021 15:14:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/03/2021 14.33, Arnd Bergmann wrote: > On Tue, Mar 23, 2021 at 4:57 PM Rasmus Villemoes > wrote: >> On 23/03/2021 14.04, Arnd Bergmann wrote: >>> if (securedisplay_cmd->status == TA_SECUREDISPLAY_STATUS__SUCCESS) { >>> + int pos = 0; >>> memset(i2c_output, 0, sizeof(i2c_output)); >>> for (i = 0; i < TA_SECUREDISPLAY_I2C_BUFFER_SIZE; i++) >>> - sprintf(i2c_output, "%s 0x%X", i2c_output, >>> + pos += sprintf(i2c_output + pos, " 0x%X", >>> securedisplay_cmd->securedisplay_out_message.send_roi_crc.i2c_buf[i]); >>> dev_info(adev->dev, "SECUREDISPLAY: I2C buffer out put is :%s\n", i2c_output); >> >> Eh, why not get rid of the 256 byte stack allocation and just replace >> all of this by >> >> dev_info(adev->dev, ""SECUREDISPLAY: I2C buffer out put is: %*ph\n", >> TA_SECUREDISPLAY_I2C_BUFFER_SIZE, >> securedisplay_cmd->securedisplay_out_message.send_roi_crc.i2c_buf); >> >> That's much less code (both in #LOC and .text), and avoids adding yet >> another place that will be audited over and over for "hm, yeah, that >> sprintf() is actually not gonna overflow". >> >> Yeah, it'll lose the 0x prefixes for each byte and use lowercase hex chars. > > Ah, I didn't know the kernel's sprintf could do that, that's really nice. If you're bored, you can "git grep -E -C4 '%[0.]2[xX]'" and find places that are inside a small loop, many can trivially be converted to %ph, though often with some small change in formatting. If you're lucky, you even get to fix real bugs when people pass a "char" to %02x and "know" that that will produce precisely two bytes of output, so they've sized their stack buffer accordingly - boom when "char" happens to be signed and one of the bytes have a value beyond ascii and %02x produces 0xffffffXX. %ph has a hard-coded upper bound of 64 bytes, I think that's silly because people instead do these inefficient and very verbose loops instead, wasting stack, .text and runtime. Rasmus 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=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 E879CC433C1 for ; Wed, 24 Mar 2021 14:14:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E78F61992 for ; Wed, 24 Mar 2021 14:14:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E78F61992 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rasmusvillemoes.dk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C6D36EB8D; Wed, 24 Mar 2021 14:14:40 +0000 (UTC) Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by gabe.freedesktop.org (Postfix) with ESMTPS id BF9136EB8D for ; Wed, 24 Mar 2021 14:14:39 +0000 (UTC) Received: by mail-ej1-x62f.google.com with SMTP id l4so33114521ejc.10 for ; Wed, 24 Mar 2021 07:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=FCHZXs+Na6H0beDmf/OCng/T5K6DKQZL7k9xPgulymE=; b=CSmURK4SwSnVaLiGIPpo0hW0XaafR3WnY0Kktfn6Q8w2WAkQ2pI/vtZsaqDMr+Rrqm 3j9+izYQ4UqWXHMKZToSCUpFRjOnIXY8UJy2FWXpJpqMTZ1LwLqfqxHXjI3T7WuIhnJ3 rDX0OvQ/BcN4cPnIJD1S57p05tgOJZ1lraw5U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FCHZXs+Na6H0beDmf/OCng/T5K6DKQZL7k9xPgulymE=; b=TceopF+pitCF36Gs5IZzZ0QLaXWKaKoUYCpyJeQxKqg73biag8A8578kNPElPKtsCr CcEKQZhoGTPqVl8fkfb4zV7VIt/ZlIYt/AqCMyvO9WbExf2bbjlx/726HdeCdTuN4qrp h3Ke9BGI9ILvMqb7MUiFYRGmcv17Y3JG0O4J0/DYFeVhn0szSA/ThoO8/tkjcr38sE3p zP9cvNFASDT54Sl3Jjyrv5SDDX9d+Ju3yo7NwWKDfQJPI22FSwC8bvkazOMyfqXCr5ql wqFxt4Seo2WCHF1WF5ckHgSvRr96O6i9O/bJvCSkQ4AxEamjDE7Ae/OVO9foefrYOekR dLDQ== X-Gm-Message-State: AOAM532tZKpa9LyP6cQVQvZnB4kK6QEcYodTL7MzAtxZDzGb2l37zYyD lJSx71HzHlvFrRcSDv7qgQt1ig== X-Google-Smtp-Source: ABdhPJww1pdM64UL62x05vVdAART6xCBNzDfZeqUIHi/5inBRmV8dfVIuzHdABjEJtiJD1nhk3/fww== X-Received: by 2002:a17:906:8447:: with SMTP id e7mr3979848ejy.523.1616595278353; Wed, 24 Mar 2021 07:14:38 -0700 (PDT) Received: from [192.168.1.149] ([80.208.71.248]) by smtp.gmail.com with ESMTPSA id c10sm1179885edt.64.2021.03.24.07.14.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Mar 2021 07:14:37 -0700 (PDT) Subject: Re: [PATCH] amdgpu: fix gcc -Wrestrict warning To: Arnd Bergmann References: <20210323130430.2250052-1-arnd@kernel.org> From: Rasmus Villemoes Message-ID: <4e63dbbc-0aa3-2950-dda1-1e6aa19d7d5d@rasmusvillemoes.dk> Date: Wed, 24 Mar 2021 15:14:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jinzhou Su , David Airlie , Linux Kernel Mailing List , amd-gfx list , Huang Rui , dri-devel , Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 24/03/2021 14.33, Arnd Bergmann wrote: > On Tue, Mar 23, 2021 at 4:57 PM Rasmus Villemoes > wrote: >> On 23/03/2021 14.04, Arnd Bergmann wrote: >>> if (securedisplay_cmd->status == TA_SECUREDISPLAY_STATUS__SUCCESS) { >>> + int pos = 0; >>> memset(i2c_output, 0, sizeof(i2c_output)); >>> for (i = 0; i < TA_SECUREDISPLAY_I2C_BUFFER_SIZE; i++) >>> - sprintf(i2c_output, "%s 0x%X", i2c_output, >>> + pos += sprintf(i2c_output + pos, " 0x%X", >>> securedisplay_cmd->securedisplay_out_message.send_roi_crc.i2c_buf[i]); >>> dev_info(adev->dev, "SECUREDISPLAY: I2C buffer out put is :%s\n", i2c_output); >> >> Eh, why not get rid of the 256 byte stack allocation and just replace >> all of this by >> >> dev_info(adev->dev, ""SECUREDISPLAY: I2C buffer out put is: %*ph\n", >> TA_SECUREDISPLAY_I2C_BUFFER_SIZE, >> securedisplay_cmd->securedisplay_out_message.send_roi_crc.i2c_buf); >> >> That's much less code (both in #LOC and .text), and avoids adding yet >> another place that will be audited over and over for "hm, yeah, that >> sprintf() is actually not gonna overflow". >> >> Yeah, it'll lose the 0x prefixes for each byte and use lowercase hex chars. > > Ah, I didn't know the kernel's sprintf could do that, that's really nice. If you're bored, you can "git grep -E -C4 '%[0.]2[xX]'" and find places that are inside a small loop, many can trivially be converted to %ph, though often with some small change in formatting. If you're lucky, you even get to fix real bugs when people pass a "char" to %02x and "know" that that will produce precisely two bytes of output, so they've sized their stack buffer accordingly - boom when "char" happens to be signed and one of the bytes have a value beyond ascii and %02x produces 0xffffffXX. %ph has a hard-coded upper bound of 64 bytes, I think that's silly because people instead do these inefficient and very verbose loops instead, wasting stack, .text and runtime. Rasmus _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel 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=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 CA726C433E2 for ; Wed, 24 Mar 2021 14:16:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6549E61A14 for ; Wed, 24 Mar 2021 14:16:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6549E61A14 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rasmusvillemoes.dk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=amd-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 166676EBA3; Wed, 24 Mar 2021 14:16:43 +0000 (UTC) Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by gabe.freedesktop.org (Postfix) with ESMTPS id C06666EB8F for ; Wed, 24 Mar 2021 14:14:39 +0000 (UTC) Received: by mail-ej1-x62c.google.com with SMTP id r12so33145114ejr.5 for ; Wed, 24 Mar 2021 07:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=FCHZXs+Na6H0beDmf/OCng/T5K6DKQZL7k9xPgulymE=; b=CSmURK4SwSnVaLiGIPpo0hW0XaafR3WnY0Kktfn6Q8w2WAkQ2pI/vtZsaqDMr+Rrqm 3j9+izYQ4UqWXHMKZToSCUpFRjOnIXY8UJy2FWXpJpqMTZ1LwLqfqxHXjI3T7WuIhnJ3 rDX0OvQ/BcN4cPnIJD1S57p05tgOJZ1lraw5U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FCHZXs+Na6H0beDmf/OCng/T5K6DKQZL7k9xPgulymE=; b=F6GHMyJaJZI3ujdWTGsY47Kh5Mt859zNZrYLotWeUq0dRwGZ7agm1/ZCZscdbS9qB5 pRZTmGCCjciLAjf3aYRa88QifwqdjrUIZVxmOUcv2/V9QTk/Zklx2Jx3v+hZHK2dYFLT s2jxRf4SSKx3oZ5zlmNLFtQlS9KxRhv+c7q6KKgS+1ahS9r8l3ZkWT7ToWvMO7YOqQmD 3PmKqlBraDaHf5O15MtdgaTayxe80/zgH2ZZvBC7JYIHU4tCSR+tfZa3pks+5apwD71I 6VsmaQ64s+qNG/6qWp3zrsvfZSpBgqhoF1WQhLS0VkMoTeNzUnJ/6+Wff6HwHnj6Y8ng 27Uw== X-Gm-Message-State: AOAM530nvJVb89a2sodpU/Dv6kENIK+sM39bLuQy+g8mjCY+jZWTVP/0 I2gQ/Mcd3Yaa0pZPz8cS8IUheA== X-Google-Smtp-Source: ABdhPJww1pdM64UL62x05vVdAART6xCBNzDfZeqUIHi/5inBRmV8dfVIuzHdABjEJtiJD1nhk3/fww== X-Received: by 2002:a17:906:8447:: with SMTP id e7mr3979848ejy.523.1616595278353; Wed, 24 Mar 2021 07:14:38 -0700 (PDT) Received: from [192.168.1.149] ([80.208.71.248]) by smtp.gmail.com with ESMTPSA id c10sm1179885edt.64.2021.03.24.07.14.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Mar 2021 07:14:37 -0700 (PDT) Subject: Re: [PATCH] amdgpu: fix gcc -Wrestrict warning To: Arnd Bergmann References: <20210323130430.2250052-1-arnd@kernel.org> From: Rasmus Villemoes Message-ID: <4e63dbbc-0aa3-2950-dda1-1e6aa19d7d5d@rasmusvillemoes.dk> Date: Wed, 24 Mar 2021 15:14:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Mailman-Approved-At: Wed, 24 Mar 2021 14:16:42 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jinzhou Su , David Airlie , Linux Kernel Mailing List , amd-gfx list , Huang Rui , dri-devel , Daniel Vetter , Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" On 24/03/2021 14.33, Arnd Bergmann wrote: > On Tue, Mar 23, 2021 at 4:57 PM Rasmus Villemoes > wrote: >> On 23/03/2021 14.04, Arnd Bergmann wrote: >>> if (securedisplay_cmd->status == TA_SECUREDISPLAY_STATUS__SUCCESS) { >>> + int pos = 0; >>> memset(i2c_output, 0, sizeof(i2c_output)); >>> for (i = 0; i < TA_SECUREDISPLAY_I2C_BUFFER_SIZE; i++) >>> - sprintf(i2c_output, "%s 0x%X", i2c_output, >>> + pos += sprintf(i2c_output + pos, " 0x%X", >>> securedisplay_cmd->securedisplay_out_message.send_roi_crc.i2c_buf[i]); >>> dev_info(adev->dev, "SECUREDISPLAY: I2C buffer out put is :%s\n", i2c_output); >> >> Eh, why not get rid of the 256 byte stack allocation and just replace >> all of this by >> >> dev_info(adev->dev, ""SECUREDISPLAY: I2C buffer out put is: %*ph\n", >> TA_SECUREDISPLAY_I2C_BUFFER_SIZE, >> securedisplay_cmd->securedisplay_out_message.send_roi_crc.i2c_buf); >> >> That's much less code (both in #LOC and .text), and avoids adding yet >> another place that will be audited over and over for "hm, yeah, that >> sprintf() is actually not gonna overflow". >> >> Yeah, it'll lose the 0x prefixes for each byte and use lowercase hex chars. > > Ah, I didn't know the kernel's sprintf could do that, that's really nice. If you're bored, you can "git grep -E -C4 '%[0.]2[xX]'" and find places that are inside a small loop, many can trivially be converted to %ph, though often with some small change in formatting. If you're lucky, you even get to fix real bugs when people pass a "char" to %02x and "know" that that will produce precisely two bytes of output, so they've sized their stack buffer accordingly - boom when "char" happens to be signed and one of the bytes have a value beyond ascii and %02x produces 0xffffffXX. %ph has a hard-coded upper bound of 64 bytes, I think that's silly because people instead do these inefficient and very verbose loops instead, wasting stack, .text and runtime. Rasmus _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx