Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4176813rwb; Mon, 31 Jul 2023 02:46:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlEC1I2640FEeWiNlCLnSwXN3YUkHZLslTgyvQ+biFed+QdevoWiyvGCS3OZ4f00TS3n3/3Z X-Received: by 2002:a05:6358:d194:b0:130:df70:b9cd with SMTP id ka20-20020a056358d19400b00130df70b9cdmr8440843rwb.12.1690796775692; Mon, 31 Jul 2023 02:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690796775; cv=none; d=google.com; s=arc-20160816; b=GacGMcmRpXb9WoSdsk3MvQm2gl5JHxL2+SYBOw+o6qtfomlToGNxIpODlwXOhwzu1s PR0qIdN6ewxA0RvmQ83MMndnfnnGpM+dPCz8xb308wCBLdOFFXlGtxlf7Hsm8ZwhO7IB cbXDC9LjChHxxBAMdoEZk2JlVomP2XYJdoXMTiPibd30MHZnnFEH8vrdmIdOWNHs4GEE gpz+24VVbY2Jwthkdwx+cv72nIHpi6AY1ZM80qYn0VFgvtu6VATeC3hd/u657WLDe/CF B0jXHFrhrjYz25iysTpPpJJujjL7D5zMpwWlCkU9+Gadub4YbeBk9K3IhWkHN1lz6s4e htjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=3fq/cbXGs/QxPb7Eea+s0s7hsPmjDBgYbWThXAxt1KQ=; fh=u8FNBzTD7PPmCCS6ytaoGcyOSB3wUBR1jDQZwmXE3V4=; b=FdcEGBXGQjnwiAlq2DDSennYbFtVjn2dFOjOj6NDyfmFAunlp1btmBCEUMTPp/+UAU x19LfyVyzwKGa6jXjbuAEtFR/mk8IMsZCiO/bPSIZxQ+PjxqVOeqx5RKDBzsCoZhPevG EsahjENWQvrrLCnsRBn6GkpjaovnrE0c8p7ift072hI2/u449acMOlN20+02rsbxAVOO tYc/X+OBasaEP3JRGyYa9vWEeA/aaMi7WjC3UyxbejoKY/4bRaP299Qpcy1v1PpMDhOj hlkP+MRC8fpgcxL006gwp9b7gqoRBYn14O/WVnwXyVYSpM9WypTJKJtErn7vV2Vtlsw2 ueFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L1G6UGNI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 38-20020a631366000000b00563fbbe378dsi6870145pgt.347.2023.07.31.02.46.03; Mon, 31 Jul 2023 02:46:15 -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; dkim=pass header.i=@linaro.org header.s=google header.b=L1G6UGNI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231984AbjGaIV5 (ORCPT + 99 others); Mon, 31 Jul 2023 04:21:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbjGaIVX (ORCPT ); Mon, 31 Jul 2023 04:21:23 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3C6A10DC for ; Mon, 31 Jul 2023 01:20:57 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4fe3c7f16bbso238042e87.0 for ; Mon, 31 Jul 2023 01:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690791656; x=1691396456; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=3fq/cbXGs/QxPb7Eea+s0s7hsPmjDBgYbWThXAxt1KQ=; b=L1G6UGNI87/2QMFnmY6w3M2a2U9lTfnzXHHx+YO8F+gQXHL5MaQXSOsO/lo2NzVDGB xJ8oaiZP/6xpzZER7nuVF116u9sLH4k11Lz3HHZeUc/rgwXluSybDnGyLkVSZpi1VdJd 7NWZZQn/ldE/aWqp1l79AQuRJto7EHyxnXWwDLVa0iTG2GU3buER3Z15DaNstkq4LXYn fCe99s7IkCTkaFP+oH8Lcmzc315i3B/mWBLFqtsvc7cqpl6ULyQMqDqvnpJIUPJK9kwq C60qxtd0l0ClA0/E+G1c7ZHgx521G/685EBtno6+Efc+mBdlTIGcNptq7RBTJ7B31+Ku t1bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690791656; x=1691396456; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3fq/cbXGs/QxPb7Eea+s0s7hsPmjDBgYbWThXAxt1KQ=; b=B5D1kQpNkUmAVMMzkXQ5oT+C3p8S3ogD7P7BsapHVDMNTrtnrwSy5Jr5LGFFhsa8mC eToVAlQLy9AxULx5A+J2WVN4ZOQcxXRUQAP4Hy5DpM8+niHCXIZ1DUOV/wqgPYh1A5oO fYoQwBL8DUT1FmDXyslkb1aeTDVpbkKN8T+R6oL9I93QbfeF6Twg0PMpOcjGQVvUaHn9 Rij4p1pgWXq7wAp5df1tZD7xkm+y0PDskpo31iEFI238PLYw9vWJYFKhxcBlVZYKe0AX 1A7xo+Xy6nvOlbtdTESEVhGHSE+6Oo43hb4xhxZ6nbcAc8OX/l5UlcbcU1EsmzDfWHfP FD1A== X-Gm-Message-State: ABy/qLaQrrqXmjNQj6whoKM5QMU8XmiYr48eT0VDy9gmIKYcT94O5X48 ZgdRYkGMPz0WuctrCS+Hfnu6uioAvKPEzbM1Dezpwg== X-Received: by 2002:a19:641e:0:b0:4fe:85c:aeba with SMTP id y30-20020a19641e000000b004fe085caebamr4639898lfb.21.1690791656271; Mon, 31 Jul 2023 01:20:56 -0700 (PDT) Received: from [192.168.1.101] (abyk53.neoplus.adsl.tpnet.pl. [83.9.30.53]) by smtp.gmail.com with ESMTPSA id y7-20020ac24207000000b004fbc6a8ad08sm1979206lfh.306.2023.07.31.01.20.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Jul 2023 01:20:55 -0700 (PDT) Message-ID: <0b1b5224-b891-bf6d-8d6f-f5d236890127@linaro.org> Date: Mon, 31 Jul 2023 10:20:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/4] soc: qcom: aoss: Format string in qmp_send() Content-Language: en-US To: Bjorn Andersson , Bjorn Andersson , Chris Lew Cc: Alex Elder , "David S. Miller" , Jakub Kicinski , Mathieu Poirier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org References: <20230731041013.2950307-1-quic_bjorande@quicinc.com> <20230731041013.2950307-4-quic_bjorande@quicinc.com> From: Konrad Dybcio Autocrypt: addr=konrad.dybcio@linaro.org; keydata= xsFNBF9ALYUBEADWAhxdTBWrwAgDQQzc1O/bJ5O7b6cXYxwbBd9xKP7MICh5YA0DcCjJSOum BB/OmIWU6X+LZW6P88ZmHe+KeyABLMP5s1tJNK1j4ntT7mECcWZDzafPWF4F6m4WJOG27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C nas9J77uICis2WH7N8Bs9jy0wQYezNzqS+FxoNXmDQg2jetX8en4bO2Di7Pmx0jXA4TOb9TM izWDgYvmBE8= In-Reply-To: <20230731041013.2950307-4-quic_bjorande@quicinc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 31.07.2023 06:10, Bjorn Andersson wrote: > The majority of callers to qmp_send() composes the message dynamically > using some form of sprintf(), resulting in unnecessary complication and > stack usage. > > By changing the interface of qmp_send() to take a format string and > arguments, the duplicated composition of the commands can be moved to a > single location. > > Signed-off-by: Bjorn Andersson > --- [...] > +int qmp_send(struct qmp *qmp, const char *fmt, ...) > { > long time_left; > + va_list args; > char buf[QMP_MSG_LEN]; > + int len; > int ret; > > - if (WARN_ON(IS_ERR_OR_NULL(qmp) || !data)) > + if (WARN_ON(IS_ERR_OR_NULL(qmp) || !fmt)) > return -EINVAL; > > - if (WARN_ON(strlen(data) >= sizeof(buf))) > - return -EINVAL; > + memset(buf, 0, sizeof(buf)); Wouldn't initializing the array with = { 0 } be faster? Otherwise, this looks very cool Reviewed-by: Konrad Dybcio Konrad