From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 6BA091FF0AF for ; Thu, 08 Oct 2026 09:39:33 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C3569213C3; Thu, 08 Oct 2026 09:39:30 +0200 (CEST) From: Maximiliano Sandoval To: Luke Yasuda Subject: Re: [PATCH 1/3 proxmox-rrd-migration-tool] use libc::c_char instead of i8 to fix mismatched type In-Reply-To: <20261008065200.1686526-1-jing@jing.rocks> (Luke Yasuda's message of "Thu, 8 Oct 2026 15:48:43 +0900") References: <20261008065200.1686526-1-jing@jing.rocks> User-Agent: mu4e 1.12.9; emacs 30.1 Date: Thu, 08 Oct 2026 09:39:24 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1791445164446 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.803 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: YGODLIQVL3LSNXICWQHXCH5COL5CDB4J X-Message-ID-Hash: YGODLIQVL3LSNXICWQHXCH5COL5CDB4J X-MailFrom: m.sandoval@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: pve-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: A small nit below. Luke Yasuda writes: > Otherwise this fails on non-amd64 arches: > > error[E0308]: mismatched types > --> src/main.rs:374:17 > | > 374 | source[0] = file.0.as_ptr(); > | --------- ^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8` > | | > | expected due to the type of this binding > | > = note: expected raw pointer `*const i8` > found raw pointer `*const u8` > > error[E0308]: mismatched types > --> src/main.rs:386:13 > | > 381 | let res = rrd_create_r2( > | ------------- arguments to this function are incorrect > ... > 386 | source.as_mut_ptr(), > | ^^^^^^^^^^^^^^^^^^^ expected `*mut *const u8`, found `*mut *const i8` > | > = note: expected raw pointer `*mut *const u8` > found raw pointer `*mut *const i8` > > Signed-off-by: Luke Yasuda > --- > Cargo.toml | 1 + > src/main.rs | 3 ++- > 2 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/Cargo.toml b/Cargo.toml > index 4574e32..a637278 100644 > --- a/Cargo.toml > +++ b/Cargo.toml > @@ -14,6 +14,7 @@ anyhow = "1" > pico-args = "0.5" > proxmox-async = "0.5" > crossbeam-channel = "0.5" > +libc = "0.2" > > [build-dependencies] > bindgen = "0.71" > diff --git a/src/main.rs b/src/main.rs > index 799cde8..b2b9bbe 100644 > --- a/src/main.rs > +++ b/src/main.rs > @@ -8,6 +8,7 @@ use std::{ > }; > > use anyhow::{bail, Context, Error, Result}; > +use libc::c_char; > > use proxmox_rrd_migration_tool::{rrd_clear_error, rrd_create_r2, rrd_get_context, rrd_get_error}; > > @@ -370,7 +371,7 @@ fn do_rrd_migration( > bail!("refusing to migrate metrics for {resource:?} - target already exists and 'force' not set!"); > } > > - let mut source: [*const i8; 2] = [std::ptr::null(); 2]; > + let mut source: [*const libc::c_char; 2] = [std::ptr::null(); 2]; I would recommend to use [c_char] from the standard library here. [c_char] https://doc.rust-lang.org/std/ffi/type.c_char.html > source[0] = file.0.as_ptr(); > > let target_path = CString::new(target_path.to_str().unwrap()).unwrap(); -- Maximiliano