From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6774542B2C; Wed, 17 May 2023 16:53:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EF5D411F3; Wed, 17 May 2023 16:53:07 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 06FF040041 for ; Wed, 17 May 2023 16:53:06 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NTwV1vRjMt9DzfYmzYcG8lXBfxMIt4RsRLFP0Rm7KYI/DjOgtM+iJlFfs+zkQ300cmkPITax1dnE9I3mOFQhW8gUUtwJsXrwSXDjU3tzNEUsYVDrPpGVKX8Xjla3rkQbc+EHOJl1RYFfW0Pi3mAScRatFMuoJVtqai5C8a8/pqfLkqgNxg381oD/7bRBLwI1FoDCwozL7/y/KlzOJopi6y2TVaq4jKwF+6cdkWQIuB4tIyj0HUkuPGgrCuYlPX9qEKGjv5AF7kzkWYUg79LGzrMcslydREwOWBIw+XQXtDneX6VLYUgAoCP0IOkoeSfy5u7rqn+oNkepiCn1U0bv7Q== 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=kUl37w14dk9mL0nq2RRlDsTOPgOaBBATYywlK4OD4fQ=; b=SwyOCp8MpoQVycQZN1u5fXjufQdxTZUKhmQ2caRAVWDol5ga9NgSfF7zQ8D1IZLx642z/Gm8H4UCgaKxOF0c1snDjdYsGyNqydDfhndKT8Ydn4aPIZHwgLz8d80pWr32n8uBBoLkkQ3lJJh1xbyZYlz/FGvp4cHeOh35CkdiOST62lqhvN7vUBEtbWTKOJzBTPxsuFG85UbgTokFqol6bQxlSBHYiljRLJV6GEnGjitzSwoiWuRxCEFDp6R7xjcKq2gtIxatPNppHkZv88iZkQ51lZcUJpZmlYxLkX7OXAxHo4yRO9aHgQhwYoDXpNT78O4aX0mG04bf6AO92lO1LQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=kUl37w14dk9mL0nq2RRlDsTOPgOaBBATYywlK4OD4fQ=; b=wLWAfMG4TyMIYc7aDTqvsX/6ZnT9Ru+mhJgLW2HhxtNYx0STayBU7h3nRUnIsQ+60oQ6YXz8X5DnGPYou11BQUOTXt1deFurZoILMbNPqaqKLVuHT7Spb2GnBFsmp09Xv08570cInWWEUJtFIFbwe0CGgKeu1wiZn+MJaNO4lqo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by MW4PR12MB6684.namprd12.prod.outlook.com (2603:10b6:303:1ee::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Wed, 17 May 2023 14:53:04 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::7957:641d:6aba:3f9a]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::7957:641d:6aba:3f9a%4]) with mapi id 15.20.6387.033; Wed, 17 May 2023 14:53:04 +0000 Message-ID: <201bce73-59a6-cca8-5f48-556599baf73d@amd.com> Date: Wed, 17 May 2023 15:52:58 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US To: David Marchand , dev@dpdk.org Cc: Thomas Monjalon , Andrew Rybchenko References: <20230309081633.780438-1-david.marchand@redhat.com> From: Ferruh Yigit Subject: Re: [PATCH] ethdev: prefer offload names in logs In-Reply-To: <20230309081633.780438-1-david.marchand@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0540.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:319::6) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|MW4PR12MB6684:EE_ X-MS-Office365-Filtering-Correlation-Id: f44d505d-5201-4267-2ba7-08db56e66af5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mJAtXXwVS7KRhOBXy6I1b0CnjWbu6KXZIlXIddRsOpYGn1RqEcrpPCH1T6SRI7W8RyXKHqFDX2mVcQ4VujERsk/yGfZtVypMybwi9KLGS7C1fN/yNDhsLwf73P278IojOmwDohMY5H8rbuROPHO6RKiVSoohaNO7HOZJOK1O+YNiJ8lXnhf5PuNJOedUAA2BRZpesjxFTCWzAyMNNBVm6AH76hyrvqTN9ycQrZIAyDNUoOToZ3VPY8GyhDYhRP7yZS1lJikuyg0P6nVPXMrmR6gXT0enmbX+VJUpWYs3FqqF7SSCp246uVnYVqVlZ9o8Lgq6bP8OJM2RcRM1BZo/44NKBkzwKIfy0xh3aefhD1Glsy632DNWChCurTj4ppZntXkfLF32+mo4JXf5AH/FhqStucHCJZvH11KIfqf5aYx2StjPzkxbf9p4Bp6FpsgcOW/nME/jvElPN6O1VUCgG0yIa0ZINhnqco2AR8DorMUU0hVKWvTlhZEp3Q7CrfLmoTPCoKGUBkriC7CmIIj0rhsfQNzPfMMi47qS6RROm6u1XVHkTEprTnXOH1pMFf4FYSjUpyRxdFUXBOtP0u87EoHqvx2I/XWhsgmYAVa7CZl3VVN0s8n0K3OrUgTgvwXdPaLNIJ0JBPUt2r6kT30Cjw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(366004)(136003)(39860400002)(346002)(376002)(451199021)(36756003)(6486002)(4326008)(54906003)(316002)(86362001)(66946007)(66476007)(66556008)(478600001)(6666004)(5660300002)(41300700001)(8676002)(44832011)(2906002)(8936002)(31696002)(38100700002)(6512007)(26005)(186003)(53546011)(6506007)(83380400001)(2616005)(31686004)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VDZqd2xPQW5WY21meE1QZVFSOExubTdlb3pvZHM2ZHNUdU1qUXZXT2Y4UU8y?= =?utf-8?B?TmZ2OXU2ak1XQ2I1eTZ6VUhhM0tYV0JSTDdDV1VkTlpzRGE1RFFSaHhVRVla?= =?utf-8?B?SlcxTlUrVzZoYUlTNmxoeWV6MWlja3AvY3FSdkRoTkUwa09FM0tLdDJQUUZT?= =?utf-8?B?U3Z2N0dtVG1OQ0grNHJrUkRFYmg5VW1PSjE1N3huNkl6ZGprUHpmTWI4RytR?= =?utf-8?B?Z0YycTNhUEliWGZKZ1BkdlhTdUwvU3pqNmZuT3NaZitmRzdUZ0ZUKzhBWUFY?= =?utf-8?B?NS9PNEx5RTcvcWFkZWtMbE00MHNRblpNV0x4ZU9wQkl2L1diU2Q3d3d2aW1C?= =?utf-8?B?dWw3Z2NGSmtwMFBPSm4wNWJueUQxUnl1SnJMak90YUJ4em12V3ZMUUpYeTE4?= =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1dmRYZnNnS2w2?= =?utf-8?B?Z29TZll0cHRBM0kvOE4reU14NmRFczZma2JLRHdyYk05Q3pTUWdtNXViSVA4?= =?utf-8?B?RjdJaGlzd0dETENBQWpORmN1Nm5wNHQ0ekNRa1ZicHNac093YjMyVmhUankr?= =?utf-8?B?VXdDWWFySUcvbEdXTHc3UEtVcnlzblVZbnJFTzhvM0wrcGlhbEw4RmN0T0NU?= =?utf-8?B?VkdDbUF3Zm5JL0N1eXo3VU5FM1pYNXhlSThGdGU0b01UVVpLdHVncVp3TkNZ?= =?utf-8?B?eXl6d2FEWVNmUElsVk1RZXlHYnNzQTA5NjdOeVBWRXBxalRxRWx4bWhVZDdE?= =?utf-8?B?T0NzcFl4ZUhDaGpMOG84eGtQZUVxbExaK3pUVi96L2Fvb2dobVFqZ2NnN3Vv?= =?utf-8?B?d0NXT0MyTXZESWEveE54UC9hc0poUWhLdUpZNXlZV2kvVkVmbGkwY2I2SWxq?= =?utf-8?B?S3lzSEZTSzNPQjlBVE1oNzRseHZHRmVzeHNQMmFqNk1xRTZ1NjZ4R0tPOWhN?= =?utf-8?B?M1lROVJhREFnOEdzUG91TWRENytSbEozYzFTVXBDVEZVS3BneGx2VStrdHpC?= =?utf-8?B?aTlFRmphcG5pU1d0Y3V2N3FSaEJHcEtRK25jeHl3ZXV5K3ZtYWxzN2pmK1J0?= =?utf-8?B?U3BIMVdjUHBKSHYvMytydHNzRjNDU3BsV05VR2MwOVlMcll3NVRIT2x2a2d0?= =?utf-8?B?RDFXN3hSbGhxTUZEOHhnd1U1eFM1cVZJSlIxRWczd0NuU2tZbDVBc3o5QlpS?= =?utf-8?B?WHFhdnpMMjAxZ3QxN0Izd3VMSDdWbTRIT3N5cHN5eEkyS0Nhak9aSHg5dmVC?= =?utf-8?Q?cvBjpsoPWrukAhNQgoG4sgKtG?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f44d505d-5201-4267-2ba7-08db56e66af5 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 14:53:04.1961 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YCMQ3i/nrww9Ln+nnwSbx0lquuJX/4VDxJ2whg32wGIkcr5vNLQw1ClOcDu37Ht9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6684 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 3/9/2023 8:16 AM, David Marchand wrote: > +static char * > +eth_dev_offload_names(uint64_t bitmask, const char *(*offload_name)(uint64_t)) > +{ > + uint64_t offload; > + char *names; > + > + if (bitmask == 0) { > + names = strdup(""); > + goto out; > + } > + > + offload = RTE_BIT64(__builtin_ctzll(bitmask)); > + names = strdup(offload_name(offload)); > + if (names == NULL) > + goto out; > + > + bitmask &= ~offload; > + while (bitmask != 0) { > + char *old = names; > + int ret; > + > + offload = RTE_BIT64(__builtin_ctzll(bitmask)); > + ret = asprintf(&names, "%s,%s", old, offload_name(offload)); > + free(old); > + if (ret == -1) { > + names = NULL; > + goto out; > + } > + > + bitmask &= ~offload; > + } > + > +out: > + return names; > +} > + Above works fine, not a strong opinion but just a comment, this function is just for logging and output string will be short lived, but it does lots of memory alloc and free, and expose lot of failure points. To simplify, why not just alloc a big enough buffer, fill it in a loop and never return NULL? (Can always append "%s," and drop final ',' at the end.)