Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7619191rdb; Thu, 4 Jan 2024 02:13:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGO2BpfeeWlEvD+ZvX/963xYuqJHST4t3s0VmZGRv9GCUVRVY5vehDq788GjRTgKYsXA6tm X-Received: by 2002:a17:902:e549:b0:1d4:c2ad:4e59 with SMTP id n9-20020a170902e54900b001d4c2ad4e59mr368879plf.71.1704363208716; Thu, 04 Jan 2024 02:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704363208; cv=none; d=google.com; s=arc-20160816; b=Mtplzar3C2fV8PgJqoelnNXFu0JuxrXMAuAT14t3Z1rKrsZrnylG6g7L4s6u/A8hSZ nnIHx5hL4ALYSjwT+H42qakY7kcIeDICwcp2BILA0L4UJVigWD3jcDXApeiOsQeOfyKY A06FOZFOJ42L4LQS+00AGEPbYig7BTZuV5mjbgHVttfdQpMWFJXO4tVv7Ymt3FJm9qEA BbYbq8GOa1EFaVjsbSODt12tuFL0i3MoZBN7iSlXWd4wHzjCJY6smu1eGwIxS12PxWD6 JrMfVu7Q7B2RVeqEMTOFFDUhho48A2LqIhg5Z+awQS6TDlX7AH3taTHvb2n7X2gJb/Fa iGTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=eU6kQ5/oOYXZSZfBlaS3ZW4rC8xgKAB2NSh5JIwTFig=; fh=RpJjGiuDlOjmyoLhPwSzjbPbeK51vYo3I0V3BuRLNmU=; b=juv16TaQBlaF8JLoQ/2wEg1P8j+jUhZFJE7PXvoZ++iRtbJ4MbjydL+mY+tsGN5Qhi rdLzwzhHP8hmXPGoOA+eD0/HzCQusoZadq7u2sVSxrOZVrxzsEs1BVa1Y57p0yRNZv2w dRij3hPRV1AO4SYQ/4v6cZODzHs8DvAgBwpxTzfV3yKFg89CZA0sxzQMUemyDF0yPYxV GpgjB9JyHNz5QJM1GJ5NBo5FlPw5L7JKurb+/0FwGL38dR66yEJbBvoZRwJa/4KFQ3Ub pzC3Iq+XOW8X5QJ82wQTfdNsomzE4t7laLfmzdXuWC0fd7aHpSLtAU+x4tohHCZCc6DF j92w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=hWfltW6+; spf=pass (google.com: domain of linux-kernel+bounces-16491-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q12-20020a17090311cc00b001cfba8ff230si14238597plh.268.2024.01.04.02.13.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 02:13:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16491-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=hWfltW6+; spf=pass (google.com: domain of linux-kernel+bounces-16491-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6022E286CE9 for ; Thu, 4 Jan 2024 10:13:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B266820B18; Thu, 4 Jan 2024 10:13:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="hWfltW6+" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC71020B02; Thu, 4 Jan 2024 10:13:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id 9758F28B53B; Thu, 4 Jan 2024 10:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1704363188; bh=j+qznhwVfcrCXO97E0Jld5V71MZIo0m6mSOS1YPgQZY=; h=From:To:Cc:Subject:Date; b=hWfltW6+nBoLPlzOFWVPtgMG0gPu8GhbhV1vBgU8mzf+hQqhE3xn8SRdPIp31I3DJ cwYoV39J6/fLpULvNP2QJQ2qSRj4M63xCjm0gOaGRaAf0AkvOGfbElQIOd8ldQ8KaA oYkTuVvB46Fqvh8u+OxKh1od7uUKl2X+/07M9CJs= From: Petre Rodan To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH 0/1] tools: iio: fix iio_generic_buffer Date: Thu, 4 Jan 2024 12:12:44 +0200 Message-ID: <20240104101253.25896-1-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit While executing tools/iio_generic_buffer i was getting this fault: beagle /usr/src/linux/tools/iio # ./iio_generic_buffer -a -c 10 -N 0 -T 0 iio device number being used is 0 iio trigger number being used is 0 Auto-channels selected but some channels are already activated in sysfs Proceeding without activating any channels /sys/bus/iio/devices/iio:device0 mytmr Floating point exception The FPE was generated due to a modulo zero in size_from_channelarray() (all channels[].bytes were zero because channels[] were never populated). The root of the cause is the seekdir() function within build_channel_array(). On my system I can observe a clear difference between these two functions: seekdir(dp, 0); printf("location = %lu\n", telldir(dp)); // location == 4294967295 rewinddir(dp); printf("location = %lu\n", telldir(dp)); // location == 1 The attached patch fixed the bug for me. I'm using a BeagleBone Black devboard with an up-to-date stable branch Gentoo Linux OS on top of it. CHOST: armv7a-unknown-linux-gnueabihf kernel: mainline 6.7.0-rc6 glibc: 2.37-r7:2.2::gentoo USE="caps gd multiarch ssp static-libs -audit -cet -compile-locales -crypt -custom-cflags -doc -hash-sysv-compat -headers-only -multilib -multilib-bootstrap -nscd -perl -profile (-selinux) -stack-realign -suid -systemd -systemtap -test -vanilla" (+ contains Gentoo specific patches) Fixes: ("staging: iio: update example application.") Signed-off-by: Petre Rodan Petre Rodan (1): tools: iio: fix iio_generic_buffer tools/iio/iio_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.41.0