From patchwork Fri Jun 30 11:18:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Schilling X-Patchwork-Id: 698184 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 8B565EB64DA for ; Fri, 30 Jun 2023 11:19:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231455AbjF3LTJ (ORCPT ); Fri, 30 Jun 2023 07:19:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231724AbjF3LTF (ORCPT ); Fri, 30 Jun 2023 07:19:05 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4699E10E5 for ; Fri, 30 Jun 2023 04:19:00 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fbab0d0b88so15121505e9.0 for ; Fri, 30 Jun 2023 04:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688123939; x=1690715939; 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=hZqSw8EV3b1lBf8XWmaIEMowQm0/NeURhO4iFq1h2i0=; b=B8yv1AyKrO0bWEMmWr7K9bdAQ5dX03LbGwSBJB5Sz592L90R636lICiPHKVcYvtbkH aNVL6jkKQndiOTfs5kE7G7F5MpWrAaI2tItkBOBt3EyBtAwZuUtoZL57ehFjHopNDypR 3ZcZccv6XfaLzcvzkXKsqqITW9GE+tYgUphy0IGWitP2nRpbqRisidV40soKlI/LgH/F NNT907yM960lCYQdp+IgN1IyxHXdES6lY2PbqPTwLl/GsBmfz4J9iyTthm1ti8a8WPIG hRyq/aq7bUqPz21+eZNux2oCtzFJsaGjdNYM3fcja1Qw8ulW7oq6sM/vxNBBkvjzw1VZ yOqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688123939; x=1690715939; 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=hZqSw8EV3b1lBf8XWmaIEMowQm0/NeURhO4iFq1h2i0=; b=lywR5gNO4Hd1fKWUVCKoXCm3GNIhMXY6bpPb8cFcBr6FlPqnf6sfYNjOFwMiMiC4Q0 JsUSo00Q8pfGWe+dL38uUwzwarBHyS1LH4llXLeUlC98Uf6vObuOIOuxjoGCJOtEju+a 0y1/ec+pEmpEdpZRPXkkJIshilX0y6sSCgkjShlqmE62liFDmoagADb4lFFL5GTz3RYe fXfVZwSxcnhNoPcBK6jU63GzJplwQeEYxYwlRz35szsOJMVQEq3vs9rEerXTBupJKY72 /BEaIJhnaJ7u/dAb95RFW9O1xiLEJhFG8nZQIYc2+34i9pGgxEo3Cb1kRcMCDuFWRvz3 hTYw== X-Gm-Message-State: AC+VfDw1Xs42uQGlt6A1kLyscNlTdbSRcQgJHSYZCUfv8PxrjTsCKZg7 8VHvXX2YeGfjkebO3C9uL9QXVw== X-Google-Smtp-Source: ACHHUZ6+pvkQlXKXzPwoxJaqPxCXVIS+sNTP+l4SPf0wJ7yigvhS94DwzkTbIIZn6oK2c/BsRgOiTw== X-Received: by 2002:a7b:c40d:0:b0:3f7:c92:57a0 with SMTP id k13-20020a7bc40d000000b003f70c9257a0mr2477806wmi.14.1688123938723; Fri, 30 Jun 2023 04:18:58 -0700 (PDT) Received: from [192.168.1.127] (i5C743877.versanet.de. [92.116.56.119]) by smtp.gmail.com with ESMTPSA id u20-20020a05600c211400b003fbb618f7adsm4621917wml.15.2023.06.30.04.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 04:18:58 -0700 (PDT) From: Erik Schilling Date: Fri, 30 Jun 2023 13:18:44 +0200 Subject: [libgpiod][PATCH v2 1/4] bindings: rust: clippy: drop unnecessary casts MIME-Version: 1.0 Message-Id: <20230630-clippy-v2-1-f44447925ad6@linaro.org> References: <20230630-clippy-v2-0-f44447925ad6@linaro.org> In-Reply-To: <20230630-clippy-v2-0-f44447925ad6@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=1688123937; l=9530; i=erik.schilling@linaro.org; s=20230523; h=from:subject:message-id; bh=EMDdrZa8OfgwpVCKve3eSUAi/NDZJtaESlvIVygNjCU=; b=VnzQ38m8wkmmbKhZecWBAKmCFRwnCInafwhZBt6vNqTT/XTS2Lnf+WmSu/AIeo6tOGSQ6DOiS +R0i/DCWKvkAO+9Up9o4rR9Xen4Su5mQgxzBnPA8J6WxmvIS9qI8OR7 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 Fixes clippy warnings on these lines. Applied the suggested fix using: cargo clippy --fix clippy version: clippy 0.1.70 (90c5418 2023-05-31). 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 Fri Jun 30 11:18:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Schilling X-Patchwork-Id: 698186 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 61F61EB64D7 for ; Fri, 30 Jun 2023 11:19:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230013AbjF3LTI (ORCPT ); Fri, 30 Jun 2023 07:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232815AbjF3LTE (ORCPT ); Fri, 30 Jun 2023 07:19:04 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 151C12D69 for ; Fri, 30 Jun 2023 04:19:01 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4fb9ae4cef6so2794888e87.3 for ; Fri, 30 Jun 2023 04:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688123940; x=1690715940; 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=cdp2jklKIUHlbGZ+iyT7OxyoQgFVKjMZj0ce2OdO9AQ=; b=qqT+Surz21lrxAxQeKSE5lumODcHwazDghZALK4qbCGcGPu1iClzdnxz5+z2czJ3E+ EfNdkqeVq4D/6lg60vnfUFuYpW4tyMewrLR0HD+DFy7AoEYp6bb+yTiwZ+LZSV5//P+u 5iy/vaDB5G3HnK4pnNIntW1c3RVZ5R6htaEAZhU+oSqlFFPfCJa9UL6SLFMQ78hnk3Eq V4+DmxS2YQngFKg5TtMhULajGLfCZksrD5rWDmhVqEn66rXwROGazJPIeN2uIW1RVtrm AjlAzi+j0Q+t3SdKuWR76wFnmfqPGwOtDkDtPixhHHcvGBMSIMZSozGwZdFZZQLcjaEc PTqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688123940; x=1690715940; 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=cdp2jklKIUHlbGZ+iyT7OxyoQgFVKjMZj0ce2OdO9AQ=; b=hw+0+I3IAN2BhEzZYelPqABWnf4DvFub//2EKXxgVDoqdSODOgWn5OsDVdno/dQItK Q4rfCcM/3MHg3AjcI8GsMPZ7QzbX+oiOsTQOblhCA2VsdKVf2N+zr17k/hFw1a7osSL3 7ypjxF2KzrghScUEoe02QhtErAD86zWuLBOZZ+UAOP8nyrjY5J9fl4WRBWur+NnrKj81 a1vpFkTap9hGbkdwr36ZI4gQluB8FIg/PaKnDlBP/FuQZQ0kmKcl5sJVXqdr8C8gRo9S XPM8YY9cadIibzOYzyPLB2gOe9jo88anQ+Che/Z4wXtN+a+9o2UsdXzDixi6zOGpaDJ7 MNXA== X-Gm-Message-State: ABy/qLZQLpCArbpi8wSLnNgMU24g/9qIGEY/SKGzXDw9eJ03y0isjQ5C N7CJK0LzIlwL65r6K8G36cgU+Q== X-Google-Smtp-Source: APBJJlGGLEWrDt4KkkoXmw3JLUy6bDdcu+l5qeP3EEIYJMev2fUMNoDRD2L6/80oxNOZ0Z8x9n6snA== X-Received: by 2002:a05:6512:39c3:b0:4f9:570c:7b28 with SMTP id k3-20020a05651239c300b004f9570c7b28mr2557331lfu.32.1688123940146; Fri, 30 Jun 2023 04:19:00 -0700 (PDT) Received: from [192.168.1.127] (i5C743877.versanet.de. [92.116.56.119]) by smtp.gmail.com with ESMTPSA id u20-20020a05600c211400b003fbb618f7adsm4621917wml.15.2023.06.30.04.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 04:18:59 -0700 (PDT) From: Erik Schilling Date: Fri, 30 Jun 2023 13:18:45 +0200 Subject: [libgpiod][PATCH v2 2/4] bindings: rust: clippy: silence false-positives on casts MIME-Version: 1.0 Message-Id: <20230630-clippy-v2-2-f44447925ad6@linaro.org> References: <20230630-clippy-v2-0-f44447925ad6@linaro.org> In-Reply-To: <20230630-clippy-v2-0-f44447925ad6@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=1688123937; l=2121; i=erik.schilling@linaro.org; s=20230523; h=from:subject:message-id; bh=/7Zaz4hVCiSuNFycSloWAx0XowWxCP5nKw8JqJQfp8Q=; b=2hit4+Nru8pDNC5jytEPDV1S7CXj9kB+hqZSPHjbsrBkBfDaPa+PO0kfp7cg/5+L4TNQm9yTN LqkoePRrgjgBU31vZC3T24gbRvuuVrghTVNnT5+MFcygQonvCgZ5kli 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 clippy falsely complains about these lines. The problem is known, but unfixed [1]. So lets silence the warning until a fix is widely available. clippy version: clippy 0.1.70 (90c5418 2023-05-31). [1] https://github.com/rust-lang/rust-clippy/issues/10555 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 Fri Jun 30 11:18:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Schilling X-Patchwork-Id: 698185 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 48477C001B1 for ; Fri, 30 Jun 2023 11:19:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231724AbjF3LTK (ORCPT ); Fri, 30 Jun 2023 07:19:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232449AbjF3LTG (ORCPT ); Fri, 30 Jun 2023 07:19:06 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD424358A for ; Fri, 30 Jun 2023 04:19:02 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fbc54cab6fso9066495e9.0 for ; Fri, 30 Jun 2023 04:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688123941; x=1690715941; 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=foDn46B+pZpT2Whbht946XgZWMtJblU3mUCYvT4/IJM=; b=IszdtquCF5l84t6q4IKRsBzybSI1cba4qox1aR0rGAG4gLq3ZNV9wjQArpAp+4rQO3 8D15kUNb7VrY8zL/HzbA9F1WthgEIdm8eLux8lxS4fWZqNANaiW+d/QflirKhGnFwRnU C72ki6cjtbCAyEC/F8+WVF/1LpEzzOxF7Gr6zp7KguhQLhhezhhWexVL1rIftlhKbgOm TD3uLoGJI2OyrOfg8yTNDKYBUYlzqzO/2jTJhgwpag77OBPeKdPb9FKBbZIrSyum4C+S KN5++nE64Jy9kG7gUMl/psiwBJKuIH0AUDP6EjsgyM3Zdcg2nfy2QIRfduDidomOSAEu PuKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688123941; x=1690715941; 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=foDn46B+pZpT2Whbht946XgZWMtJblU3mUCYvT4/IJM=; b=gGshm+C6/NSSUM6gIHm0VJFtKUk5UXOrcAS4PQIGKc7JYWkjm0967YwqNjpaMvsFnc xN8unNJkgjm03pnaNWgU016i701Kh52e1Hf560RGi3B0XH48OZeA+PpAEL+GrAzVWyer rLIfMs/Kvba5m0ICZtDnGZEMA0ig8hVVKIHTsC8sMQ+vRijcPZ0Z5eDM/LGPowwrP7T2 tfBtOl9wpIRLbWRB6FmD3JNQZgda6O3dc9IH3mPrbZI20SKFBI2JJtAWmVKhoGeJgWUi +yA91xeGY35Y14uSbD093YmyAv6qrJi8145j+9JX+L2GZblYRoObZm20FfkaaJziAk4K ffZQ== X-Gm-Message-State: AC+VfDx6cxIROx8qOo/r/iop2btjsURT3nlMqxQovpLfuREhSxUrQ7hs nSmRFlSabViM6ZGeXHZQpvC5b2IsfXvjVlD3pTw= X-Google-Smtp-Source: ACHHUZ5OWOF/wU7UFBllboMbEfVLqfZrY5eneE72kjbTj9nb1B2PSmFBaPACv6wPcqRSB9po36f+qg== X-Received: by 2002:a1c:4c08:0:b0:3fb:b287:b0ad with SMTP id z8-20020a1c4c08000000b003fbb287b0admr1957215wmf.13.1688123941392; Fri, 30 Jun 2023 04:19:01 -0700 (PDT) Received: from [192.168.1.127] (i5C743877.versanet.de. [92.116.56.119]) by smtp.gmail.com with ESMTPSA id u20-20020a05600c211400b003fbb618f7adsm4621917wml.15.2023.06.30.04.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 04:19:01 -0700 (PDT) From: Erik Schilling Date: Fri, 30 Jun 2023 13:18:47 +0200 Subject: [libgpiod][PATCH v2 4/4] bindings: rust: clippy: silence false-positive on iterator MIME-Version: 1.0 Message-Id: <20230630-clippy-v2-4-f44447925ad6@linaro.org> References: <20230630-clippy-v2-0-f44447925ad6@linaro.org> In-Reply-To: <20230630-clippy-v2-0-f44447925ad6@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=1688123937; l=1136; i=erik.schilling@linaro.org; s=20230523; h=from:subject:message-id; bh=c74vXxa4MAhI21WLFDLO8nb3tQLt/j3LlAIZ9/MOxpk=; b=jo8yedh87k+2pDTwpnEkLgAqWo1Z2aEewmrX678/bCufOc2OkXl3dFxFrBJcIjuUiUaWkJbO3 n0000zki7PTC1g4fhFEEombvscGMpAYSL+V2t9au4yhFTFR/xOnVdi4 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 on clippy master [1], but it is still broken on 0.1.70. So lets silence it until the clippy fix is widely available. clippy version: clippy 0.1.70 (90c5418 2023-05-31). [1] https://github.com/rust-lang/rust-clippy/commit/9fa40894103e32364fdbade539d4ecb3d40f3d7f 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) } }