[pbs-devel] [PATCH proxmox 1/9] mark extern C blocks as unsafe
Maximiliano Sandoval
m.sandoval at proxmox.com
Tue Mar 4 15:40:43 CET 2025
This is required in edition 2024.
Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
The changes up to 'port to edition 2024' could be added as of now, the rest
require changes in debcargo.
proxmox-acme-api/src/certificate_helpers.rs | 2 +-
proxmox-async/src/runtime.rs | 2 +-
proxmox-rest-server/src/rest.rs | 2 +-
proxmox-sys/src/crypt.rs | 4 ++--
proxmox-sys/src/fs/acl.rs | 2 +-
proxmox-sys/src/linux/procfs/mod.rs | 2 +-
proxmox-sys/src/linux/timer.rs | 4 ++--
proxmox-systemd/src/sys.rs | 2 +-
proxmox-time/src/posix.rs | 2 +-
proxmox-uuid/src/lib_uuid_bindings.rs | 2 +-
10 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/proxmox-acme-api/src/certificate_helpers.rs b/proxmox-acme-api/src/certificate_helpers.rs
index d8eee604..a0d744c8 100644
--- a/proxmox-acme-api/src/certificate_helpers.rs
+++ b/proxmox-acme-api/src/certificate_helpers.rs
@@ -385,7 +385,7 @@ fn x509name_to_string(name: &openssl::x509::X509NameRef) -> Result<String, Error
#[allow(non_camel_case_types)]
type ASN1_TIME = <openssl::asn1::Asn1TimeRef as ForeignTypeRef>::CType;
-extern "C" {
+unsafe extern "C" {
fn ASN1_TIME_to_tm(s: *const ASN1_TIME, tm: *mut libc::tm) -> libc::c_int;
}
diff --git a/proxmox-async/src/runtime.rs b/proxmox-async/src/runtime.rs
index 0721fd9e..c36dea88 100644
--- a/proxmox-async/src/runtime.rs
+++ b/proxmox-async/src/runtime.rs
@@ -45,7 +45,7 @@ use tokio::runtime::{self, Runtime, RuntimeFlavor};
static RUNTIME: LazyLock<Mutex<Weak<Runtime>>> = LazyLock::new(|| Mutex::new(Weak::new()));
#[link(name = "crypto")]
-extern "C" {
+unsafe extern "C" {
fn OPENSSL_thread_stop();
}
diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs
index d23ed776..c11a9b0c 100644
--- a/proxmox-rest-server/src/rest.rs
+++ b/proxmox-rest-server/src/rest.rs
@@ -36,7 +36,7 @@ use crate::{
formatter::*, normalize_path, ApiConfig, AuthError, CompressionMethod, RestEnvironment,
};
-extern "C" {
+unsafe extern "C" {
fn tzset();
}
diff --git a/proxmox-sys/src/crypt.rs b/proxmox-sys/src/crypt.rs
index b802040b..508b9c15 100644
--- a/proxmox-sys/src/crypt.rs
+++ b/proxmox-sys/src/crypt.rs
@@ -38,7 +38,7 @@ struct CryptData {
/// Encrypt a password - see man crypt(3)
pub fn crypt(password: &[u8], salt: &[u8]) -> Result<String, Error> {
#[link(name = "crypt")]
- extern "C" {
+ unsafe extern "C" {
#[link_name = "crypt_r"]
fn __crypt_r(
key: *const libc::c_char,
@@ -87,7 +87,7 @@ pub fn crypt(password: &[u8], salt: &[u8]) -> Result<String, Error> {
/// - `rbytes`: The byte slice that contains cryptographically random bytes for generating the salt
pub fn crypt_gensalt(prefix: &str, count: u64, rbytes: &[u8]) -> Result<String, Error> {
#[link(name = "crypt")]
- extern "C" {
+ unsafe extern "C" {
#[link_name = "crypt_gensalt_rn"]
fn __crypt_gensalt_rn(
prefix: *const libc::c_char,
diff --git a/proxmox-sys/src/fs/acl.rs b/proxmox-sys/src/fs/acl.rs
index 5ae69296..29aa75ab 100644
--- a/proxmox-sys/src/fs/acl.rs
+++ b/proxmox-sys/src/fs/acl.rs
@@ -54,7 +54,7 @@ mod constants {
pub use constants::*;
#[link(name = "acl")]
-extern "C" {
+unsafe extern "C" {
fn acl_get_file(path: *const c_char, acl_type: ACLType) -> *mut c_void;
fn acl_set_file(path: *const c_char, acl_type: ACLType, acl: *mut c_void) -> c_int;
fn acl_get_fd(fd: RawFd) -> *mut c_void;
diff --git a/proxmox-sys/src/linux/procfs/mod.rs b/proxmox-sys/src/linux/procfs/mod.rs
index 0875fcf8..3b25ce70 100644
--- a/proxmox-sys/src/linux/procfs/mod.rs
+++ b/proxmox-sys/src/linux/procfs/mod.rs
@@ -20,7 +20,7 @@ pub use mountinfo::MountInfo;
/// POSIX sysconf call
pub fn sysconf(name: i32) -> i64 {
- extern "C" {
+ unsafe extern "C" {
fn sysconf(name: i32) -> i64;
}
unsafe { sysconf(name) }
diff --git a/proxmox-sys/src/linux/timer.rs b/proxmox-sys/src/linux/timer.rs
index 462af976..bb01dc81 100644
--- a/proxmox-sys/src/linux/timer.rs
+++ b/proxmox-sys/src/linux/timer.rs
@@ -70,7 +70,7 @@ type TimerT = *mut InternalTimerT;
// These wrappers are defined in -lrt.
#[link(name = "rt")]
-extern "C" {
+unsafe extern "C" {
fn timer_create(clockid: clockid_t, evp: *mut libc::sigevent, timer: *mut TimerT) -> c_int;
fn timer_delete(timer: TimerT) -> c_int;
fn timer_settime(
@@ -232,7 +232,7 @@ pub const SIGTIMEOUT: Signal = Signal(32 + 4);
// Our timeout handler does exactly nothing. We only need it to interrupt
// system calls.
-extern "C" fn sig_timeout_handler(_: c_int) {}
+unsafe extern "C" fn sig_timeout_handler(_: c_int) {}
// See setup_timeout_handler().
fn do_setup_timeout_handler() -> io::Result<()> {
diff --git a/proxmox-systemd/src/sys.rs b/proxmox-systemd/src/sys.rs
index 64075929..eabd44d1 100644
--- a/proxmox-systemd/src/sys.rs
+++ b/proxmox-systemd/src/sys.rs
@@ -5,7 +5,7 @@ use std::os::fd::RawFd;
pub const LISTEN_FDS_START: RawFd = 3;
#[link(name = "systemd")]
-extern "C" {
+unsafe extern "C" {
pub fn sd_journal_stream_fd(
identifier: *const c_uchar,
priority: c_int,
diff --git a/proxmox-time/src/posix.rs b/proxmox-time/src/posix.rs
index bb60ba04..c8064bf4 100644
--- a/proxmox-time/src/posix.rs
+++ b/proxmox-time/src/posix.rs
@@ -142,7 +142,7 @@ pub fn strftime(format: &str, t: &libc::tm) -> Result<String, Error> {
// The `libc` crate does not yet contain bindings for `strftime_l`
#[link(name = "c")]
-extern "C" {
+unsafe extern "C" {
#[link_name = "strftime_l"]
fn libc_strftime_l(
s: *mut libc::c_char,
diff --git a/proxmox-uuid/src/lib_uuid_bindings.rs b/proxmox-uuid/src/lib_uuid_bindings.rs
index 0ecd994d..e39847e4 100644
--- a/proxmox-uuid/src/lib_uuid_bindings.rs
+++ b/proxmox-uuid/src/lib_uuid_bindings.rs
@@ -3,7 +3,7 @@ use std::fmt;
use crate::Uuid;
#[link(name = "uuid")]
-extern "C" {
+unsafe extern "C" {
pub fn uuid_generate(out: *mut [u8; 16]);
fn uuid_unparse_lower(input: *const [u8; 16], out: *mut u8);
fn uuid_unparse_upper(input: *const [u8; 16], out: *mut u8);
--
2.39.5
More information about the pbs-devel
mailing list