From patchwork Thu Jun 29 11:08:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Schilling X-Patchwork-Id: 698190 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42FBBEB64DD for ; Thu, 29 Jun 2023 11:10:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232103AbjF2LKC (ORCPT ); Thu, 29 Jun 2023 07:10:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232195AbjF2LJk (ORCPT ); Thu, 29 Jun 2023 07:09:40 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 041672D50 for ; Thu, 29 Jun 2023 04:09:14 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbab0d0b88so4321385e9.0 for ; Thu, 29 Jun 2023 04:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688036952; x=1690628952; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=f6s4UJTW2s+J/uK95eQceT3Q7N5XarYkMNstNAwDygE=; b=z86K03swaTgDH/SDo+FNcXrrk/Rwpd60NqCZLC2CmQCde2Gr81686BNV4LYM8/2igt xxDNyts5UY/G/wNrf7btelKlX9x3Jfirv8McsVQtgAK4YCZSGms0wQao+Pdsar554qcl CjxLvUFl9IaCZEQMTptXF707PpAM4QvzkYMgE1kurXakcDqpiiaMOoe8xbsYfv+bz0re flBSXVb9IyV0jvtBHG5X+6+4S5n5BaIw/Xh7B9NfPJFrzQo0v94zq0H/gqn4aiQ2f8Ib 1zenmELikG5REZX2iYqTUAQjVKa6/vascKLMUGBDtVXBYqgYEYhN+wzxfhaBkIk3jzez 2q8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688036952; x=1690628952; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f6s4UJTW2s+J/uK95eQceT3Q7N5XarYkMNstNAwDygE=; b=IomGyQzcj+2u9aBE8tFa5kX+DX6b0rcM0ORodvsqtByZ+thcDShah+0BvSCUEs9TC6 4NSPKpWoYj+OmJuoziwrqE9qJFaU0c+a98GLnV+9XOvJE0yCpOClVsZzCJd11sh2slZ0 zg0A5eaaGktSkdVTGbsci3s6pStJ8yLsksIzSaXJOCWf3xnS3VZV2YqYuX9xDg96In6E jHinj8WuLxN3NTO19DMU5DE0gtLnO4ElUnRrFanJSLhjBlLCjMpEGy6StyfVOXSIhobT SnqR/04trYO1oq61ZMSdC4+SyECXb1rbgcOHN6sNQ8/WI64GSRa/r4AyUsPMp/6mop2K iRIQ== X-Gm-Message-State: AC+VfDzVym6KGHtYe4kOduNkBpsoJGF5WbuZT4+8tmorXmuqyuN4Q8cW BwzElZzSsFJ1NQ+Oi79Xek8t+ALwgcubLs6T3bA= X-Google-Smtp-Source: ACHHUZ77OnTzJOhyZbRdszB5AfRFMovmGf+/aujhH7WOgIIaHl/Hb2ipt3XHFBHIgklWIdRI1q7VUQ== X-Received: by 2002:a05:600c:1c16:b0:3fb:b18a:f32d with SMTP id j22-20020a05600c1c1600b003fbb18af32dmr4304504wms.17.1688036952373; Thu, 29 Jun 2023 04:09:12 -0700 (PDT) Received: from [192.168.1.127] (i5C7438BA.versanet.de. [92.116.56.186]) by smtp.gmail.com with ESMTPSA id cw13-20020a056000090d00b003112f836d4esm15571197wrb.85.2023.06.29.04.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 04:09:12 -0700 (PDT) From: Erik Schilling Date: Thu, 29 Jun 2023 13:08:59 +0200 Subject: [PATCH libgpiod 1/4] bindings: rust: clippy: drop unnecessary casts MIME-Version: 1.0 Message-Id: <20230629-clippy-v1-1-9ff088713c54@linaro.org> References: <20230629-clippy-v1-0-9ff088713c54@linaro.org> In-Reply-To: <20230629-clippy-v1-0-9ff088713c54@linaro.org> To: Linux-GPIO Cc: Kent Gibson , Viresh Kumar , Erik Schilling X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1688036951; l=9482; i=erik.schilling@linaro.org; s=20230523; h=from:subject:message-id; bh=Ot1V75qiEATelXlma9s8qXh3jyd7nNo0vESvJozpwlI=; b=sLuc4DCpO999c3fIjYSVlBUrNImhohLUuCb4yvozzSdY1RQQVo+tz7Bh5IkEAuCL7zsrGzVWp 7PLU6cpvyv/DFHf1mbm859BqG8l11DLfw1nbSOqLw3tP+Rbes7nG0ez X-Developer-Key: i=erik.schilling@linaro.org; a=ed25519; pk=/nNqy8/YOEdthj1epXl5FgwCTKEiVqTqqnVN1jVal7s= Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Ran cargo clippy --fix on clippy 0.1.70 (90c5418 2023-05-31). Tested build on x86_64, armv7hf, aarch64. Reported-by: Kent Gibson Link: https://lore.kernel.org/r/20230612154055.56556-1-warthog618@gmail.com Signed-off-by: Erik Schilling --- bindings/rust/gpiosim-sys/src/lib.rs | 2 +- bindings/rust/gpiosim-sys/src/sim.rs | 2 +- bindings/rust/libgpiod/src/chip.rs | 2 +- bindings/rust/libgpiod/src/edge_event.rs | 2 +- bindings/rust/libgpiod/src/event_buffer.rs | 2 +- bindings/rust/libgpiod/src/info_event.rs | 2 +- bindings/rust/libgpiod/src/lib.rs | 2 +- bindings/rust/libgpiod/src/line_config.rs | 4 ++-- bindings/rust/libgpiod/src/line_request.rs | 8 ++++---- bindings/rust/libgpiod/src/line_settings.rs | 2 +- bindings/rust/libgpiod/src/request_config.rs | 2 +- bindings/rust/libgpiod/tests/chip.rs | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bindings/rust/gpiosim-sys/src/lib.rs b/bindings/rust/gpiosim-sys/src/lib.rs index eed2a42..bf9ae32 100644 --- a/bindings/rust/gpiosim-sys/src/lib.rs +++ b/bindings/rust/gpiosim-sys/src/lib.rs @@ -46,7 +46,7 @@ impl Value { errno::errno(), )) } - _ => return Err(Error::InvalidEnumValue("Value", val as i32)), + _ => return Err(Error::InvalidEnumValue("Value", val)), }) } } diff --git a/bindings/rust/gpiosim-sys/src/sim.rs b/bindings/rust/gpiosim-sys/src/sim.rs index 896596f..16c2b3e 100644 --- a/bindings/rust/gpiosim-sys/src/sim.rs +++ b/bindings/rust/gpiosim-sys/src/sim.rs @@ -164,7 +164,7 @@ impl SimBank { errno::errno(), )) } else { - Value::new(ret as i32) + Value::new(ret) } } diff --git a/bindings/rust/libgpiod/src/chip.rs b/bindings/rust/libgpiod/src/chip.rs index f4de008..81e1be6 100644 --- a/bindings/rust/libgpiod/src/chip.rs +++ b/bindings/rust/libgpiod/src/chip.rs @@ -279,7 +279,7 @@ impl Info { /// Get the number of GPIO lines exposed by the chip. pub fn num_lines(&self) -> usize { // SAFETY: `gpiod_chip` is guaranteed to be valid here. - unsafe { gpiod::gpiod_chip_info_get_num_lines(self.info) as usize } + unsafe { gpiod::gpiod_chip_info_get_num_lines(self.info) } } } diff --git a/bindings/rust/libgpiod/src/edge_event.rs b/bindings/rust/libgpiod/src/edge_event.rs index d324ce6..0c0cfbc 100644 --- a/bindings/rust/libgpiod/src/edge_event.rs +++ b/bindings/rust/libgpiod/src/edge_event.rs @@ -41,7 +41,7 @@ impl Event { /// Get the event type. pub fn event_type(&self) -> Result { // SAFETY: `gpiod_edge_event` is guaranteed to be valid here. - EdgeKind::new(unsafe { gpiod::gpiod_edge_event_get_event_type(self.0) } as u32) + EdgeKind::new(unsafe { gpiod::gpiod_edge_event_get_event_type(self.0) }) } /// Get the timestamp of the event. diff --git a/bindings/rust/libgpiod/src/event_buffer.rs b/bindings/rust/libgpiod/src/event_buffer.rs index 1deaf2b..520eb2a 100644 --- a/bindings/rust/libgpiod/src/event_buffer.rs +++ b/bindings/rust/libgpiod/src/event_buffer.rs @@ -82,7 +82,7 @@ impl Buffer { } // SAFETY: `gpiod_edge_event_buffer` is guaranteed to be valid here. - let capacity = unsafe { gpiod::gpiod_edge_event_buffer_get_capacity(buffer) as usize }; + let capacity = unsafe { gpiod::gpiod_edge_event_buffer_get_capacity(buffer) }; Ok(Self { buffer, diff --git a/bindings/rust/libgpiod/src/info_event.rs b/bindings/rust/libgpiod/src/info_event.rs index b0ceb3b..db60600 100644 --- a/bindings/rust/libgpiod/src/info_event.rs +++ b/bindings/rust/libgpiod/src/info_event.rs @@ -34,7 +34,7 @@ impl Event { /// Get the event type of the status change event. pub fn event_type(&self) -> Result { // SAFETY: `gpiod_info_event` is guaranteed to be valid here. - InfoChangeKind::new(unsafe { gpiod::gpiod_info_event_get_event_type(self.event) } as u32) + InfoChangeKind::new(unsafe { gpiod::gpiod_info_event_get_event_type(self.event) }) } /// Get the timestamp of the event, read from the monotonic clock. diff --git a/bindings/rust/libgpiod/src/lib.rs b/bindings/rust/libgpiod/src/lib.rs index 26354e5..3acc98c 100644 --- a/bindings/rust/libgpiod/src/lib.rs +++ b/bindings/rust/libgpiod/src/lib.rs @@ -193,7 +193,7 @@ pub mod line { errno::errno(), )) } - _ => return Err(Error::InvalidEnumValue("Value", val as i32)), + _ => return Err(Error::InvalidEnumValue("Value", val)), }) } diff --git a/bindings/rust/libgpiod/src/line_config.rs b/bindings/rust/libgpiod/src/line_config.rs index e973cde..f4f03f1 100644 --- a/bindings/rust/libgpiod/src/line_config.rs +++ b/bindings/rust/libgpiod/src/line_config.rs @@ -108,7 +108,7 @@ impl Config { let mut map = SettingsMap::new(); // SAFETY: gpiod_line_config is guaranteed to be valid here let num_lines = unsafe { gpiod::gpiod_line_config_get_num_configured_offsets(self.config) }; - let mut offsets = vec![0; num_lines as usize]; + let mut offsets = vec![0; num_lines]; // SAFETY: gpiod_line_config is guaranteed to be valid here. let num_stored = unsafe { @@ -119,7 +119,7 @@ impl Config { ) }; - for offset in &offsets[0..num_stored as usize] { + for offset in &offsets[0..num_stored] { // SAFETY: `gpiod_line_config` is guaranteed to be valid here. let settings = unsafe { gpiod::gpiod_line_config_get_line_settings(self.config, *offset) }; diff --git a/bindings/rust/libgpiod/src/line_request.rs b/bindings/rust/libgpiod/src/line_request.rs index b175eea..1140aa9 100644 --- a/bindings/rust/libgpiod/src/line_request.rs +++ b/bindings/rust/libgpiod/src/line_request.rs @@ -28,12 +28,12 @@ impl Request { /// Get the number of lines in the request. pub fn num_lines(&self) -> usize { // SAFETY: `gpiod_line_request` is guaranteed to be valid here. - unsafe { gpiod::gpiod_line_request_get_num_requested_lines(self.request) as usize } + unsafe { gpiod::gpiod_line_request_get_num_requested_lines(self.request) } } /// Get the offsets of lines in the request. pub fn offsets(&self) -> Vec { - let mut offsets = vec![0; self.num_lines() as usize]; + let mut offsets = vec![0; self.num_lines()]; // SAFETY: `gpiod_line_request` is guaranteed to be valid here. let num_offsets = unsafe { @@ -43,7 +43,7 @@ impl Request { self.num_lines(), ) }; - offsets.shrink_to(num_offsets as usize); + offsets.shrink_to(num_offsets); offsets } @@ -145,7 +145,7 @@ impl Request { /// Set values of all lines associated with the request. pub fn set_values(&mut self, values: &[Value]) -> Result<&mut Self> { - if values.len() != self.num_lines() as usize { + if values.len() != self.num_lines() { return Err(Error::InvalidArguments); } diff --git a/bindings/rust/libgpiod/src/line_settings.rs b/bindings/rust/libgpiod/src/line_settings.rs index 918d6c2..79ee2f5 100644 --- a/bindings/rust/libgpiod/src/line_settings.rs +++ b/bindings/rust/libgpiod/src/line_settings.rs @@ -244,7 +244,7 @@ impl Settings { /// Get the event clock setting. pub fn event_clock(&self) -> Result { // SAFETY: `gpiod_line_settings` is guaranteed to be valid here. - EventClock::new(unsafe { gpiod::gpiod_line_settings_get_event_clock(self.settings) } as u32) + EventClock::new(unsafe { gpiod::gpiod_line_settings_get_event_clock(self.settings) }) } /// Set the output value setting. diff --git a/bindings/rust/libgpiod/src/request_config.rs b/bindings/rust/libgpiod/src/request_config.rs index 0c6c5c1..5bde7c6 100644 --- a/bindings/rust/libgpiod/src/request_config.rs +++ b/bindings/rust/libgpiod/src/request_config.rs @@ -83,7 +83,7 @@ impl Config { /// Get the edge event buffer size setting for the request config. pub fn event_buffer_size(&self) -> usize { // SAFETY: `gpiod_request_config` is guaranteed to be valid here. - unsafe { gpiod::gpiod_request_config_get_event_buffer_size(self.config) as usize } + unsafe { gpiod::gpiod_request_config_get_event_buffer_size(self.config) } } } diff --git a/bindings/rust/libgpiod/tests/chip.rs b/bindings/rust/libgpiod/tests/chip.rs index f264708..60b4ecc 100644 --- a/bindings/rust/libgpiod/tests/chip.rs +++ b/bindings/rust/libgpiod/tests/chip.rs @@ -59,7 +59,7 @@ mod chip { assert_eq!(info.label().unwrap(), LABEL); assert_eq!(info.name().unwrap(), sim.chip_name()); assert_eq!(chip.path().unwrap(), sim.dev_path().to_str().unwrap()); - assert_eq!(info.num_lines(), NGPIO as usize); + assert_eq!(info.num_lines(), NGPIO); } #[test] From patchwork Thu Jun 29 11:09:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Schilling X-Patchwork-Id: 698189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0419EC001B1 for ; Thu, 29 Jun 2023 11:10:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232212AbjF2LKF (ORCPT ); Thu, 29 Jun 2023 07:10:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232197AbjF2LJk (ORCPT ); Thu, 29 Jun 2023 07:09:40 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 968133593 for ; Thu, 29 Jun 2023 04:09:14 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fa7512e599so5544105e9.2 for ; Thu, 29 Jun 2023 04:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688036953; x=1690628953; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=N8RHvmB7ld/wK77znijVaEXaus1IN747vmI4vnxSxYM=; b=CwskU3imi73Lan4d2vPIOrLgrAfztapxw4zTw0OHdv9j+JblCMxn+N3N/IIS9fu7S5 5kcPoOM/XB2GjerLArqJF0OHTC0lsx+vNOSBgu80TtasfKSs4U/I/IeMXgEi7vokSPRe nS+spUpIjYwpnwJGXSdqK4EX0ZHqBRg4THQTrn6VQSVufGqtYm9Q/0qv85nINj8aUZ/P sV2fax2Tue69syIoPwIXFbQLY2Ibw3tiVetliRr2FYerK4BOs+4IgPDsghoby14NU1BB 1fJA5F3uGWNPJk5tCdlvjTXBuCNAX7Lv012g1to7gzEdVtWCN5U/fbPnp6HRKFrOT0WX Pjeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688036953; x=1690628953; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N8RHvmB7ld/wK77znijVaEXaus1IN747vmI4vnxSxYM=; b=Z/r4+oJaeX6lVm2aF7xcg3JBwJtGBtAOLSQZwqSNNs6pOgbAGvzirb2AKzH+aZaZ4T 4Z//HERmodJ/mjGLdRhHY8QvOpTAKrPPxE0Dd4cPd6AXX0SAsmXbX20gO5eUdKESYXef mgJ9FZBof+RTR9azvw5R4y2xdrt1CrF7u/JIXUOby516s5ZYZw/H5xs41fNnHSafzATl uCQlIuWWuq44U4JarURRHCJ/pApEV18EL2SFJXPwyBDRzB6qUD/4fkLtSUymiAeyMoP2 FDorsC9iJ5cV6Al4Q9DgU9aTAuqJaqyCw+AHQZF8VoX26uEMBUpXxE6yoWw4mQJa/is9 l0Mg== X-Gm-Message-State: AC+VfDyiC08olgG9BTPRQUQXc/qfWjCtYlUDGtr5jmp4Z9JIASJ7vUGk a7HiIaiQ+e6DQluVJy/09eULMswZDjnbMeEuEXE= X-Google-Smtp-Source: ACHHUZ6NigSoMPK3SMVu2kD03BMATxyNjXqqN9h28kUKxz8GCb0RnS8VI/cv2RnNBvAcnb9ByfF9HA== X-Received: by 2002:a7b:cb8f:0:b0:3fa:973e:2995 with SMTP id m15-20020a7bcb8f000000b003fa973e2995mr8724842wmi.12.1688036953007; Thu, 29 Jun 2023 04:09:13 -0700 (PDT) Received: from [192.168.1.127] (i5C7438BA.versanet.de. [92.116.56.186]) by smtp.gmail.com with ESMTPSA id cw13-20020a056000090d00b003112f836d4esm15571197wrb.85.2023.06.29.04.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 04:09:12 -0700 (PDT) From: Erik Schilling Date: Thu, 29 Jun 2023 13:09:00 +0200 Subject: [PATCH libgpiod 2/4] bindings: rust: clippy: silence false-positives on casts MIME-Version: 1.0 Message-Id: <20230629-clippy-v1-2-9ff088713c54@linaro.org> References: <20230629-clippy-v1-0-9ff088713c54@linaro.org> In-Reply-To: <20230629-clippy-v1-0-9ff088713c54@linaro.org> To: Linux-GPIO Cc: Kent Gibson , Viresh Kumar , Erik Schilling X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1688036951; l=1902; i=erik.schilling@linaro.org; s=20230523; h=from:subject:message-id; bh=+Y9l9n+fPMuYUZfj7h/wwtWgGxBDe0fk5hZvkvpJF5o=; b=aRox3aiy2GpgYkS/A4NZyZgiCQ/NJz34yhSyF1W88xMJ6xIv7mBMXDlQiseVgBR7nA4E1oUfR MZpfHSL66VWCs2xw3I3gzsfDfH9SWkxbWTsB3lZISChTP9JP/uVulXT X-Developer-Key: i=erik.schilling@linaro.org; a=ed25519; pk=/nNqy8/YOEdthj1epXl5FgwCTKEiVqTqqnVN1jVal7s= Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Tested build on x86_64, armv7hf, aarch64. Reported-by: Kent Gibson Link: https://lore.kernel.org/r/20230612154055.56556-1-warthog618@gmail.com Signed-off-by: Erik Schilling --- bindings/rust/libgpiod/src/line_info.rs | 3 +++ bindings/rust/libgpiod/src/line_settings.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/bindings/rust/libgpiod/src/line_info.rs b/bindings/rust/libgpiod/src/line_info.rs index 702f1b4..c4f488c 100644 --- a/bindings/rust/libgpiod/src/line_info.rs +++ b/bindings/rust/libgpiod/src/line_info.rs @@ -142,6 +142,9 @@ impl Info { /// Get the debounce period of the line. pub fn debounce_period(&self) -> Duration { + // c_ulong may be 32bit OR 64bit, clippy reports a false-positive here: + // https://github.com/rust-lang/rust-clippy/issues/10555 + #[allow(clippy::unnecessary_cast)] // SAFETY: `gpiod_line_info` is guaranteed to be valid here. Duration::from_micros(unsafe { gpiod::gpiod_line_info_get_debounce_period_us(self.info) as u64 diff --git a/bindings/rust/libgpiod/src/line_settings.rs b/bindings/rust/libgpiod/src/line_settings.rs index 79ee2f5..f0b3e9c 100644 --- a/bindings/rust/libgpiod/src/line_settings.rs +++ b/bindings/rust/libgpiod/src/line_settings.rs @@ -218,6 +218,9 @@ impl Settings { /// Get the debounce period. pub fn debounce_period(&self) -> Result { + // c_ulong may be 32bit OR 64bit, clippy reports a false-positive here: + // https://github.com/rust-lang/rust-clippy/issues/10555 + #[allow(clippy::unnecessary_cast)] // SAFETY: `gpiod_line_settings` is guaranteed to be valid here. Ok(Duration::from_micros(unsafe { gpiod::gpiod_line_settings_get_debounce_period_us(self.settings) as u64 From patchwork Thu Jun 29 11:09:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Schilling X-Patchwork-Id: 697810 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF581EB64DC for ; Thu, 29 Jun 2023 11:10:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232195AbjF2LKD (ORCPT ); Thu, 29 Jun 2023 07:10:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232212AbjF2LJk (ORCPT ); Thu, 29 Jun 2023 07:09:40 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 181873596 for ; Thu, 29 Jun 2023 04:09:15 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-313e34ab99fso564614f8f.1 for ; Thu, 29 Jun 2023 04:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688036953; x=1690628953; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=V6JGgBC9El8dhrOzeQnHhabqG5Il9YZSVayP4JvpXkw=; b=OJgUwH+2xp+VXzhcJEj5I/eiaQBEEfKcBlBKsyYh8HK5ssT1nLBS72C8V7zV9THon0 ZgJqXC6ZWOq3bkFPuMpN+/r9yIjBuol02+RiIS+pyn5GZK//icIZj+ypjC1LwqdD8m9C hKObhTLlTNVml4gTQXoH9ADKqfHB6dPCsHfBzw+VZtNhl0xyhFRI0kusfFXQetXUO7N9 QIAIUqEeelbA0atHMbpVaT1hG16nVqhDnEO2b0/UyK7zHkkv33H9mI70iYPsKW5hFfYx CIpCSsRVj18SzLc5lDQgGtner6OoK9nSGbREbT4pV3pNZyr2nQjCsEI1UNyfJ55KvXXq fOEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688036953; x=1690628953; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V6JGgBC9El8dhrOzeQnHhabqG5Il9YZSVayP4JvpXkw=; b=UG1WDs5kVuDqdFg+leACO33fEaGmgZN2tjtnlDuyXnDrbzwz7DjQK3lGl/GCaJEpPe d/Gd9McpcSeaaes7GBwlT0xfkoL6Y0xvOjP3dVDdwff1eFAId77+HSz5xHMgxzfaZp1t t5OTX6hpBniGgod85QOkc9T13JqZ408JxbGpoznlvRc/+o9bKzCCKqmZ60pvHbrqZ+CV LYSZFYeAU8WX1mTiqe3ZttTGCOO2O47EHp69JoMLm7mQhJKTnd6Vw+Zya/5528AO9tyd 20W+rdUuTweCg3jgRwI8XFJyqOw5pRL2iUlCXoCQOoWBSEeB/pa8Q1D9/2bclzgNMYyk Qf4g== X-Gm-Message-State: AC+VfDzCbTyWSg1bCmz11oaEEafPKjLdutNgckpXQt5c/OaWDRsq14KD +OPOG1D+8RgfuTAB3cclUfH/zBAZcjvCB8gzL3Q= X-Google-Smtp-Source: ACHHUZ4yQ/obiONl+vByhuTMQrpK7DuJHTRRFnharBjPJxX/BFzsgs1sgZ0XYq8EYCJbMgXteNondg== X-Received: by 2002:a5d:6a85:0:b0:314:c93:79fd with SMTP id s5-20020a5d6a85000000b003140c9379fdmr3862417wru.29.1688036953640; Thu, 29 Jun 2023 04:09:13 -0700 (PDT) Received: from [192.168.1.127] (i5C7438BA.versanet.de. [92.116.56.186]) by smtp.gmail.com with ESMTPSA id cw13-20020a056000090d00b003112f836d4esm15571197wrb.85.2023.06.29.04.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 04:09:13 -0700 (PDT) From: Erik Schilling Date: Thu, 29 Jun 2023 13:09:01 +0200 Subject: [PATCH libgpiod 3/4] bindings: rust: clippy: drop unneeded conversions MIME-Version: 1.0 Message-Id: <20230629-clippy-v1-3-9ff088713c54@linaro.org> References: <20230629-clippy-v1-0-9ff088713c54@linaro.org> In-Reply-To: <20230629-clippy-v1-0-9ff088713c54@linaro.org> To: Linux-GPIO Cc: Kent Gibson , Viresh Kumar , Erik Schilling X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1688036951; l=1654; i=erik.schilling@linaro.org; s=20230523; h=from:subject:message-id; bh=X5OP4eeAxxS0VNQ54POfDetV3O/sUCRZBKm25Yei+XE=; b=Ap6UYiprvyxDnyoODrRqZoz+eI7HK6zcBqqaAAnMNFakSIOUOAJ888SgerUE0G3ERw8NyO7+a Ki9325kPj6XA11islxVZrZUTUaSN1B3F9wx2VmL4Y+KD2c18R8srgFV X-Developer-Key: i=erik.schilling@linaro.org; a=ed25519; pk=/nNqy8/YOEdthj1epXl5FgwCTKEiVqTqqnVN1jVal7s= Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Ran cargo clippy --fix on clippy 0.1.70 (90c5418 2023-05-31). Tested build on x86_64, armv7hf, aarch64. Reported-by: Kent Gibson Link: https://lore.kernel.org/r/20230612154055.56556-1-warthog618@gmail.com Signed-off-by: Erik Schilling --- bindings/rust/gpiosim-sys/src/sim.rs | 2 +- bindings/rust/libgpiod/src/event_buffer.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/rust/gpiosim-sys/src/sim.rs b/bindings/rust/gpiosim-sys/src/sim.rs index 16c2b3e..71b9453 100644 --- a/bindings/rust/gpiosim-sys/src/sim.rs +++ b/bindings/rust/gpiosim-sys/src/sim.rs @@ -186,7 +186,7 @@ impl SimBank { fn set_num_lines(&self, num: usize) -> Result<()> { // SAFETY: `gpiosim_bank` is guaranteed to be valid here. - let ret = unsafe { gpiosim_bank_set_num_lines(self.bank, num.try_into().unwrap()) }; + let ret = unsafe { gpiosim_bank_set_num_lines(self.bank, num) }; if ret == -1 { Err(Error::OperationFailed( OperationType::SimBankSetNumLines, diff --git a/bindings/rust/libgpiod/src/event_buffer.rs b/bindings/rust/libgpiod/src/event_buffer.rs index 520eb2a..b79e9ea 100644 --- a/bindings/rust/libgpiod/src/event_buffer.rs +++ b/bindings/rust/libgpiod/src/event_buffer.rs @@ -108,7 +108,7 @@ impl Buffer { gpiod::gpiod_line_request_read_edge_events( request.request, self.buffer, - self.events.len().try_into().unwrap(), + self.events.len(), ) }; From patchwork Thu Jun 29 11:09:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Schilling X-Patchwork-Id: 698188 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD0AEC001B1 for ; Thu, 29 Jun 2023 11:10:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232324AbjF2LKM (ORCPT ); Thu, 29 Jun 2023 07:10:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232217AbjF2LJk (ORCPT ); Thu, 29 Jun 2023 07:09:40 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2826359A for ; Thu, 29 Jun 2023 04:09:15 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3113dabc549so679133f8f.1 for ; Thu, 29 Jun 2023 04:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688036954; x=1690628954; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gjWAD3xgu1+4S9LVLxxSlciTYFK1Sbr5R+tn3bj2G0k=; b=gVWClMK0LMEjCA+Cr66MLnP07kew3KsobGBHni4riMV5vplGsj8nWwxkIHYf3P9k3w gzfMP9sop6jIPWPsos++orMAXmPGy0vEFJ7TJnNy4rb+08h2ljRax2E0vhoBbI1i6mNz rcksmEUi43xhXZuOAmTJIK4l97IhnUGLkwUSKS5x7pEAO6Iz/y5qw+xf23hAxBBvFXQe jNitli+KX7Q3SINOL8YSTJhUXBoJ0SHKZ8mnAddhH/paA9aMYwg7TNI2/bkJpOQNnkjU A8aWO38fD3mUbHI43jEpbE7LcGhV5FW4xZyuFBY5i2LSz7Iyf230dn9K8T+7RDcFu4q5 EzYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688036954; x=1690628954; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gjWAD3xgu1+4S9LVLxxSlciTYFK1Sbr5R+tn3bj2G0k=; b=FnGvce55dpTyDSJQLO53Py1QdWQuHoclJwqJdRarkmAsCT82nnxk3QJ0tOyxPHFnM6 9oQTo9TvUbirdEl//oUWYVkK1P1ILBTnrW4m3+0lZmkOPijqGmQoY0GnzfEk0R0qVZbn K9F39/rKgsXT6h4mu5EydOuy5AGcBt010cP+aGX/SOsPQOFwA1QcMNnC6FZgPbT4pbfs H2dNjUTZmjqH1DOFm35azqdHtX/4kpBRWNPDaStR5mA+zRWWV809A0VkkYwLrXvoEkrU wkbZW9ZG1knYRUeiJpPquRae9eC3rEkg0291BNUU5A29FJF3gH8ZZ3TaMKyfT7MQT3WA 2bqw== X-Gm-Message-State: AC+VfDxWlWoha9rFJJPTzuV4B4o8bCqBWfzsXY0JwPPqqow0bt2yeHva l4/MoNrgn9rKbNmxWOU5mvi88w== X-Google-Smtp-Source: ACHHUZ6Agms1izqZFq2ZEz4/xWdZhilG1zJqIP2O4Qko/5OhsErvaRZ21jXg362o2tmXb0YmL2EBpw== X-Received: by 2002:a5d:62d2:0:b0:313:e8f9:dbfa with SMTP id o18-20020a5d62d2000000b00313e8f9dbfamr16802417wrv.35.1688036954300; Thu, 29 Jun 2023 04:09:14 -0700 (PDT) Received: from [192.168.1.127] (i5C7438BA.versanet.de. [92.116.56.186]) by smtp.gmail.com with ESMTPSA id cw13-20020a056000090d00b003112f836d4esm15571197wrb.85.2023.06.29.04.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 04:09:14 -0700 (PDT) From: Erik Schilling Date: Thu, 29 Jun 2023 13:09:02 +0200 Subject: [PATCH libgpiod 4/4] bindings: rust: clippy: silence false-positive on iterator MIME-Version: 1.0 Message-Id: <20230629-clippy-v1-4-9ff088713c54@linaro.org> References: <20230629-clippy-v1-0-9ff088713c54@linaro.org> In-Reply-To: <20230629-clippy-v1-0-9ff088713c54@linaro.org> To: Linux-GPIO Cc: Kent Gibson , Viresh Kumar , Erik Schilling X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1688036951; l=942; i=erik.schilling@linaro.org; s=20230523; h=from:subject:message-id; bh=9Ef2blUdIBqaRS/IvtnkKFRbjUV0UgyUroU9uhls5MA=; b=7rBiZI2yUc3BFbljxJKD23EYBxc3RFIJSdb/gbUyqoSboDq/t5299DiitZ6pXDkl9s0wn8FwB yp07eYcDXEpA8nCuVIJvXCYaZrOPutSBQdULkeSntvKOnP670pCPIBI X-Developer-Key: i=erik.schilling@linaro.org; a=ed25519; pk=/nNqy8/YOEdthj1epXl5FgwCTKEiVqTqqnVN1jVal7s= Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This was fixed, but it is not in stable yet. Tested build on x86_64, armv7hf, aarch64. Reported-by: Kent Gibson Link: https://lore.kernel.org/r/20230612154055.56556-1-warthog618@gmail.com Signed-off-by: Erik Schilling --- bindings/rust/libgpiod/src/event_buffer.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bindings/rust/libgpiod/src/event_buffer.rs b/bindings/rust/libgpiod/src/event_buffer.rs index b79e9ea..2e4bfd3 100644 --- a/bindings/rust/libgpiod/src/event_buffer.rs +++ b/bindings/rust/libgpiod/src/event_buffer.rs @@ -54,6 +54,9 @@ impl<'a> Iterator for Events<'a> { } fn next(&mut self) -> Option { + // clippy false-positive, fixed in next clippy release: + // https://github.com/rust-lang/rust-clippy/issues/9820 + #[allow(clippy::iter_nth_zero)] self.nth(0) } }