Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D8EDC28D13 for ; Thu, 25 Aug 2022 08:59:28 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 453C884860; Thu, 25 Aug 2022 10:59:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="aoQ2nVIb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 44B2584860; Thu, 25 Aug 2022 10:59:25 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2076.outbound.protection.outlook.com [40.107.93.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8AA74841AB for ; Thu, 25 Aug 2022 10:59:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=michal.simek@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nXWg2Qf0n+Ta1oltJtYoP9QwvYHpJ4MCeNfkg/UuI/pGAazMCCvaBN2ck66CBznYe2LDUF+YImpGwqc9mdEd0wPgy8OucbHMJ8ja4abts/BRmscm8EtaSmP92HyGz3sCGo0gHSVi5Nmw+1fwp7MScxjC/eYd4oeEh8CHdfG7AQHOVk+9g/P40SZ0gTi6rS6Xy+Hh/r++v1wLCNfXyXjNhsNfs1REMfkThzKnWcZBC+9ex+hDfXOrNAz8x0tCapvHHxSsRMQWJm1Obgbq5o2VLy0P938W8Ht18XZJQv+ov6GgimWqhT425wuEwi6JCySOobHyUdRsBPra23qP2+hphQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hYCmpVPohMQ8W0hx73Q9qTwjCNFI97sDEAOG4bHyQmw=; b=Y2I4OSxv0pXiqSh6x+7EtwGCw44YQf/xMtTSjXuF4rsp8N1mWDMSJkthQo0s9HcS/zBWdfoIotNYnGUWNkz76ToQYtKQn0xmwzJV1ftOCVN+pD5r2doHs0Q9PL3c/iWWyZJg5gSAbrAdD43ufEYO8klKzBXI4/JeUEk964Aa7vlDSfJeDQfRY2afpbqsgvBSmG4DDxnKV2vij4Ekvi+6ApSiy7ZHHlrC9Oi3SK+rjEr8xdtgGtgHlE9vP2oWptjaIgAx79f1VEzUduOG6s89N6zl3pDXCmzdtVvvgqg9VVgsfBiatPCdGqeAC8ZYUu/atKNoS6xH1OF4HCNbt/vGiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gmail.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hYCmpVPohMQ8W0hx73Q9qTwjCNFI97sDEAOG4bHyQmw=; b=aoQ2nVIbAczZx9YcZUQZhl6kcVKVTFuy1p6nDbUEvatHnOekaGY+iSYi7zahS2ejlauDeWKPmIgyDgP7WcYUyne4DGyAd/6t0GhQfXPERBh9Z/I7IxbMmifhcPrdXCpAZe55xRGDulxwMiQRdtisfiHRgpJPw7PQ9d2p9SXgbpA= Received: from BN6PR2001CA0006.namprd20.prod.outlook.com (2603:10b6:404:b4::16) by BN9PR12MB5354.namprd12.prod.outlook.com (2603:10b6:408:103::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Thu, 25 Aug 2022 08:59:19 +0000 Received: from BN8NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:404:b4:cafe::dd) by BN6PR2001CA0006.outlook.office365.com (2603:10b6:404:b4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15 via Frontend Transport; Thu, 25 Aug 2022 08:59:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT032.mail.protection.outlook.com (10.13.177.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5566.15 via Frontend Transport; Thu, 25 Aug 2022 08:59:19 +0000 Received: from [10.254.241.52] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 25 Aug 2022 03:59:17 -0500 Message-ID: <7e423cc1-5f95-fb5b-a227-dbe31aa924c6@amd.com> Date: Thu, 25 Aug 2022 10:59:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH 2/4] cpu: microblaze: remove unused ret variable Content-Language: en-US To: Ovidiu Panait , CC: Michal Simek References: <20220825064131.673958-1-ovpanait@gmail.com> <20220825064131.673958-2-ovpanait@gmail.com> From: Michal Simek In-Reply-To: <20220825064131.673958-2-ovpanait@gmail.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b83660d8-d3b4-4aae-fc16-08da86781896 X-MS-TrafficTypeDiagnostic: BN9PR12MB5354:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Lgm4jHhkaF5+F3PnDvVdh+pKOKjQ7hxINNob9xDscC8S3XxnCic447S+gWxOm8aaBiu/rSKU5j7MUooHWE0tdq2pFSEhrfjWag6Fz0arK8L3bYYMJpYcbs7KtGouC4nCbiGd8UhYkXmdSd5D17QEaZmidlBSNreZlsCt5GDtjfP5GG3y4szeVI4yLDoRCc3u2KS75lB+1ht0ZKlCQz/QkAMGzrUM6QEAAX+LR/S/UR4xHetwO7a+02AZP98muEkQuIffcJ6ShIuKzNJAZqlBD/6rH7KVHKm8rNqn1NJ25/V8o6TDK+4Hhjxh4MexK62v6biiNMS7WUWzHEbIj+d9AcHqwj/TajbuMwq4z+onkce+cvsUGkw2J4ENtChhvsSjpJZZavRy8WE7sYjObDnQjceDduAkutqAsIde/9qxXMtNLZgNVgeNnxKy02j8t7Jl95fwBuJm5/wEl2UnT8wyd07hTPzCWuuOehAhyqpngNm++kddDRNf5s5k9pLZmjbRDCKvSgKpCaNhgI9BR1+FNcKiAYV1SR4+4UKZBISM5TySO+aAuwhFpQ6jNv31fZb/cIYqg1PFNo2Z9/Z5jVdeflIYPUfewZhfdaOHi6qYnKAlgg5B89e/WLiSnE/KmTeUaRtYZDj3OsZG+IrqXSpUuPaPo6rF9IYJIyU3vkpU5zUF7NI+LIaOsTOczjWo5qaykJuYsf+LdnS1zA00v+SSntJWnxyBKjJPXdPJdl2As+rY2n3JIe3tDr5VM6rK9aQJicVS2KSStMlLXAJjO8tBidOL77uHSH1dG3+9sSn4iF0ZCyToGksLbUzNUR0sGm86F0u7xpLWjfVuSjWEnmjcJQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230016)(4636009)(346002)(376002)(39860400002)(396003)(136003)(46966006)(36840700001)(40470700004)(336012)(83380400001)(31686004)(186003)(2616005)(36756003)(478600001)(41300700001)(26005)(2906002)(6666004)(47076005)(53546011)(36860700001)(426003)(16526019)(40460700003)(82740400003)(5660300002)(44832011)(81166007)(8936002)(82310400005)(40480700001)(31696002)(316002)(16576012)(110136005)(70586007)(4326008)(8676002)(356005)(70206006)(86362001)(36900700001)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 08:59:19.2310 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b83660d8-d3b4-4aae-fc16-08da86781896 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5354 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On 8/25/22 08:41, Ovidiu Panait wrote: > Drop the unused ret variable from microblaze_cpu_get_desc(). > > Signed-off-by: Ovidiu Panait > --- > > drivers/cpu/microblaze_cpu.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/cpu/microblaze_cpu.c b/drivers/cpu/microblaze_cpu.c > index 969a1047e5..4eae06a8a6 100644 > --- a/drivers/cpu/microblaze_cpu.c > +++ b/drivers/cpu/microblaze_cpu.c > @@ -88,15 +88,14 @@ static int microblaze_cpu_get_desc(const struct udevice *dev, char *buf, > struct microblaze_cpuinfo *ci = gd_cpuinfo(); > const char *cpu_ver, *fpga_family; > u32 cpu_freq_mhz; > - int ret; > > cpu_freq_mhz = ci->cpu_freq / 1000000; > cpu_ver = microblaze_lookup_cpu_version_string(ci->ver_code); > fpga_family = microblaze_lookup_fpga_family_string(ci->fpga_code); > > - ret = snprintf(buf, size, > - "MicroBlaze @ %uMHz, Rev: %s, FPGA family: %s", > - cpu_freq_mhz, cpu_ver, fpga_family); > + snprintf(buf, size, > + "MicroBlaze @ %uMHz, Rev: %s, FPGA family: %s", > + cpu_freq_mhz, cpu_ver, fpga_family); > > return 0; > } First of all I think you can remove DECLARE_GLOBAL_DATA_PTR from drivers/cpu/microblaze_cpu.c I looked at the code and I think that there are some things what should happen. First of all I would memset by 0 that buf which is passed and I think this should be done in uclass to make sure that you won't show anything what it is on the stack where buf is allocated in cmd/cpu.c for example. The second if snprintf fails we shouldn't ignore that error because if you do that that means that buffer is valid and you can print content. For cpu_freq_mhz I think that make sense to allocate some space in string. For example %4u gives you exact size GHz should be fine for now. cpu_ver has max size 6 now and family string has 18 chars now. It means change string to this with some chars on the top should be fine for me. ret = snprintf(buf, size, "MicroBlaze @ %5uMHz, Rev: %7s, FPGA family: %20s", cpu_freq_mhz, cpu_ver, fpga_family); And then check that ret is equal XX size would be easy for checking and returning 0 if they match. Thanks, Michal