Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp430465rdg; Tue, 10 Oct 2023 15:00:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGUR21XnkNnBezITIm8qqNNUn/T8LAK1lintGpDJ3MkiV2YQbx/U4WqqDC98eTpv3AG20Nu X-Received: by 2002:a05:6a20:8e01:b0:16b:79b3:2285 with SMTP id y1-20020a056a208e0100b0016b79b32285mr15978770pzj.56.1696975237783; Tue, 10 Oct 2023 15:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696975237; cv=none; d=google.com; s=arc-20160816; b=mLCBoObwtz+M4NxSImbj2SyAQq7wRvbQ0aw7m/CRVfPyfMxztZasl5JfaEVAH08AEU i98KV1+AAO40G5jXvRiEbfy1pdWE7E5uAPmexr4Xqp5mstAjjrw8FPcYMODo8hJCKppf QcWa8s4ePxPwMm/Pu9j1g3FHKH2APOosOBMAE7dSAADzIofqKXxwMRm3FnWPXE7EKnYi D5/BDkOLOO/ptVbPC89SXd0lBIuLL/Ho95TpVXt121DKBXauH6a5inKq6lX5VV1/JWf4 ss/bfOW938OygmVz5hz9DGbeGNlFTi1z5iMPfzZZv2daw+PK0Ge0PW1Rw+BLOn580NSs Qnhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=6oUHI/XemOwFByi9CcHJ6Rkka7yVy2KN4Ko9d/nmv6s=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=AuD5oVXKd3nWPzFoBu0TCAgE6DFzcTlTuqot02rAwA/U0Wv/f/bKwmJAt7W4kmf3S/ S2COhhysAETKAYCu0KtC8c7tTKyJzw5/I1STM83i6Gg4YHmsUj4krd2j0Dk/GlkSOtQa HnfYMWsIC50fvP+KkCiqYDYGFyiFKm/rFi9vkpFBF3bCFxiRJAPqHJTTtdO7Ia5D9g9N Id9b/Mn2fn7AwUNF+cmJyPnKTrDQGW8Z9abvTo9a0gN6XcwzL237kTJCPgc+IQb7exGs S6fvzcVB0LNoaR2z0UTJqm/kFGvwGGuJDvwwPzerslOlxZ/iCLMlc8RDp6ki6KKOxXcW T0Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="H/BtUtYK"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id f15-20020a056a00238f00b0069100de2235si10809753pfc.187.2023.10.10.15.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 15:00:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="H/BtUtYK"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4134C807EDBC; Tue, 10 Oct 2023 15:00:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229547AbjJJV65 (ORCPT + 99 others); Tue, 10 Oct 2023 17:58:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbjJJV65 (ORCPT ); Tue, 10 Oct 2023 17:58:57 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 543E498 for ; Tue, 10 Oct 2023 14:58:56 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c77449a6daso52999485ad.0 for ; Tue, 10 Oct 2023 14:58:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696975135; x=1697579935; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=6oUHI/XemOwFByi9CcHJ6Rkka7yVy2KN4Ko9d/nmv6s=; b=H/BtUtYKfzO1815HhlZkuShv537aZtcMMAo0qXx3D4CNpWBvyzYONCDV7UYqCyTIH1 MB6BATULf5N9sxpylZo2W0y623v296ukE1E44tdDWUC/70iQyMRwXH0qRkisqKFkLcjd 0zFD/O+gdRhnkWPpKGHaCJQkJmn4BtY54j655SXOh654c6WV4ZhHJvO8VC2HgdxgBGnU u+rkBmHj4rr8UoUJTmjOiRXsSFGjhBKbJ+AHInDAxFVqk9xzwxmLM03eEGxwTynAkTNE qGq4yfu1uXZp1iPElcaA2rE14hJCkQQTQz88/UQdBi4shYQiyNRS74xVv6wu/TRmtxX9 1I4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696975135; x=1697579935; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6oUHI/XemOwFByi9CcHJ6Rkka7yVy2KN4Ko9d/nmv6s=; b=PDaQBzTEftc0YPWVRAINCBdi2B9iCU3J2v0RL38NoEYycqZAeoZs9QdDgxFZwzvvVB MXgMydwr1N6xMXgv+EI1Q7HP6JYFBvP7sMtw76yUHqFlOpYuPtGKMZJ+zWi02XIE6lUf cdA/2BbO5xXz2HgcOnL8B0eguegEKG+loNlH1XmQpfkVn7i7yhB1AxTN42VwXKaggdVT BYOnBEqaST+cx2X7i8MRwGEYJBvxw+0fejl/UGbku9HSVHJho9dDZSkr3IWoNBo/uqIJ dhjeVkiQVgdEjNwXJVxcF0mMUeJLkmEyFy7N5wfQcy5tELNPCZieYx0N5cvuHK40a5R/ CtJw== X-Gm-Message-State: AOJu0YwbsDki39XZLjhyMBu/5q5O6bQv5AxViez3SLjma3iQD+Wr1S+M bue0EWKJIe43x84LXZ1dO1KYKxAbsaHzwQruHu8= X-Received: by 2002:a17:903:2445:b0:1c7:4ab6:b3cc with SMTP id l5-20020a170903244500b001c74ab6b3ccmr24190047pls.54.1696975134901; Tue, 10 Oct 2023 14:58:54 -0700 (PDT) Received: from lvondent-mobl4.. (c-98-232-221-87.hsd1.or.comcast.net. [98.232.221.87]) by smtp.gmail.com with ESMTPSA id t24-20020a1709028c9800b001c73f51e61csm12305322plo.106.2023.10.10.14.58.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 14:58:54 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] input: Fix smatch warning Date: Tue, 10 Oct 2023 14:58:52 -0700 Message-ID: <20231010215853.629963-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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-bluetooth@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 10 Oct 2023 15:00:36 -0700 (PDT) From: Luiz Augusto von Dentz This fixes the following warning: profiles/input/device.c:165:26: warning: Variable length array is used. --- profiles/input/device.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index 4310dd192e11..6c64ff1c1c52 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "lib/bluetooth.h" #include "lib/hidp.h" @@ -162,32 +163,33 @@ static bool hidp_send_message(GIOChannel *chan, uint8_t hdr, { int fd; ssize_t len; - uint8_t msg[size + 1]; + struct iovec iov[2]; if (!chan) { error("BT socket not connected"); return false; } + iov[0].iov_base = &hdr; + iov[0].iov_len = sizeof(hdr); + if (data == NULL) size = 0; - msg[0] = hdr; - if (size > 0) - memcpy(&msg[1], data, size); - ++size; + iov[1].iov_base = (void *)data; + iov[1].iov_len = size; fd = g_io_channel_unix_get_fd(chan); - len = write(fd, msg, size); + len = writev(fd, iov, 2); if (len < 0) { error("BT socket write error: %s (%d)", strerror(errno), errno); return false; } - if ((size_t) len < size) { + if ((size_t) len < size + 1) { error("BT socket write error: partial write (%zd of %zu bytes)", - len, size); + len, size + 1); return false; } -- 2.41.0