Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1872460imw; Sat, 9 Jul 2022 13:51:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tsifLLSX0V2kJ64rzfYQ5I3W3dkPoQ0J9eenWoBpArs5LZuvTL3juhFp+b3JvlxRfDg6AX X-Received: by 2002:a17:907:d05:b0:6f4:3729:8e36 with SMTP id gn5-20020a1709070d0500b006f437298e36mr10638782ejc.475.1657399887779; Sat, 09 Jul 2022 13:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657399887; cv=none; d=google.com; s=arc-20160816; b=bjAosqoCAE8RawibiNaiSChy7zJxpj+/Icc/0iKqOHEvKpDS5CjFXuN0ApuyT6OXPI p4CcU5yjJ1KNNVBzyXBT8h8NAgAJu1NWVDD32qcd+xC/zVoRE8mJ5enRq3k6bo0AhhIb MZIwv78EbP5e8APdIVxmKLBpSlCxQ4sseP6ETlKx63bd1BHR8YgDkYpKRGgOn/9ynypc E/yJlP3Bxkr1gM/5fycq/Iw8y+I9Bw5ru80qlN9YH4RUlSfoXk+XYW5g0sqCUYT++3PD SWEpmvfLZundrJadcohwyJhMsYKTCt3hhvvhFSnKitWmhJzFr9E6VqYGTCDsONvtntpr 77Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=5w8SMBIH8DllO01er4iHEMKHEjwRVgP6ggngmP50RQM=; b=M8fofNIWdqBq5ObWeK8WTlT8P1NRL4o3o3ks/moQHc51BvxGv5/aqsoAppsXF9DLwj 7whRUKDhARadLLFI10S3nAPSReQkeTlPngydZAi7olqz7ab18iHagkM6jTAKrkSgiExT QJ9/EfJseV8iF+DNJfYrYCQ1yvESSImR0Ln4fAQFdGwXwgket4fk+/Dnlu3GXsT/aPIT AzKYQC6b7DG0LZuaQRokPsZ2ER603LH6ySFBDMw1YuN/H6UIaoGpQ52TuArESuRfFY2/ 8h1M60v3cplg+Xt1d4SRfOqt8zTiSViEn4VUR1euIlVKimjcuJBMycZ3veNLZ8929I4K Jr/A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m12-20020a056402510c00b0043a93d806ccsi1460995edd.449.2022.07.09.13.51.02; Sat, 09 Jul 2022 13:51:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229561AbiGIUmR (ORCPT + 99 others); Sat, 9 Jul 2022 16:42:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbiGIUmQ (ORCPT ); Sat, 9 Jul 2022 16:42:16 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9750513F04 for ; Sat, 9 Jul 2022 13:42:15 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6400,9594,10403"; a="283213830" X-IronPort-AV: E=Sophos;i="5.92,259,1650956400"; d="scan'208";a="283213830" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2022 13:42:15 -0700 X-IronPort-AV: E=Sophos;i="5.92,259,1650956400"; d="scan'208";a="594460189" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2022 13:42:11 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1oAHHE-0019Qg-0W; Sat, 09 Jul 2022 23:42:08 +0300 Date: Sat, 9 Jul 2022 23:42:07 +0300 From: Andy Shevchenko To: Cezary Rojewski Cc: =?iso-8859-1?Q?P=E9ter?= Ujfalusi , Andy Shevchenko , Mark Brown , ALSA Development Mailing List , Takashi Iwai , Jaroslav Kysela , amadeuszx.slawinski@linux.intel.com, Pierre-Louis Bossart , Hans de Goede , Ranjani Sridharan , Linux Kernel Mailing List , Liam Girdwood , Kai Vehmanen , Bard Liao Subject: Re: [PATCH 1/2] lib/string_helpers: Introduce strsplit_u32() Message-ID: References: <6c8e4104-2239-a188-649d-585f059cabdd@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 09, 2022 at 10:45:49AM +0200, Cezary Rojewski wrote: > On 2022-07-08 6:49 PM, Andy Shevchenko wrote: > > On Fri, Jul 8, 2022 at 6:32 PM Cezary Rojewski > > wrote: > > > > > > On 2022-07-08 5:25 PM, Andy Shevchenko wrote: > > > > On Fri, Jul 8, 2022 at 2:34 PM P?ter Ujfalusi > > > > wrote: > > > > > A long shot, but what if we were to modify get_options() so it takes > > > additional element-size parameter instead? > > > > But why? int / unsigned int, u32 / s32 are all compatible in the current cases. > > I'd like to avoid any additional operations, so that the retrieved payload > can be provided to the IPC handler directly. The IPC handlers for AudioDSP > drivers are expecting payload in u32s. > > // u32 **tkns, size_t *num_tkns as foo() arguments > // u32 *ints, int nints as locals > > get_options(buf, 0, &nints); > if (!nints) { > ret = -ENOENT; > goto free_buf; > } > > ints = kcalloc(nints + 1, sizeof(*ints), GFP_KERNEL); > if (!ints) { > ret = -ENOMEM; > goto free_buf; > } > > get_num_options(buf, nints + 1, ints, sizeof(*ints)); > > *tkns = ints; > *num_tkns = nints; > > No additional operations in between. The intermediate IPC handler can later > refer to the actual payload via &tkns[1] before passing it to the generic > one. > > Casting int array into u32 array does not feel right, or perhaps I'm missing > something like in the doc case. C standard. int to unsigned int is not promoted. And standard says that "The rank of any unsigned integer type shall equal the rank of the corresponding signed integer type, if any." I don't know why one needs to have an additional churn here. int and unsigned int are interoperable with the adjustment to the sign when the other argument is signed or lesser rank of. -- With Best Regards, Andy Shevchenko