diff src/libpam/memory.rs @ 185:fb8b547b36b7

Banish al(most al)l use of `i32` in favor of `c_int`.
author Paul Fisher <paul@pfish.zone>
date Thu, 31 Jul 2025 14:45:38 -0400
parents a1bb1d013567
children 5e4ea9650f87
line wrap: on
line diff
--- a/src/libpam/memory.rs	Thu Jul 31 14:36:50 2025 -0400
+++ b/src/libpam/memory.rs	Thu Jul 31 14:45:38 2025 -0400
@@ -13,16 +13,18 @@
 macro_rules! num_enum {
     (
         $(#[$m:meta])*
-        $viz:vis enum $name:ident($repr:ty) {
+        $viz:vis enum $name:ident {
             $(
                 $(#[$im:meta])*
                 $item_name:ident = $item_value:path,
             )*
         }
     ) => {
+        // This is the one place where we depend upon c_int being i32.
+        // Ideally, we would be able to say `repr(c_int)` but we can't.
         $(#[$m])*
         #[derive(Clone, Copy, Debug, Eq, PartialEq)]
-        #[repr($repr)]
+        #[repr(i32)]
         $viz enum $name {
             $(
                 $(#[$im])*
@@ -30,11 +32,11 @@
             )*
         }
 
-        impl TryFrom<$repr> for $name {
+        impl TryFrom<c_int> for $name {
             type Error = crate::constants::ErrorCode;
 
             #[allow(unused_doc_comments)]
-            fn try_from(value: $repr) -> crate::constants::Result<$name> {
+            fn try_from(value: c_int) -> crate::constants::Result<$name> {
                 match value {
                     $(
                         $(#[$im])*
@@ -45,9 +47,9 @@
             }
         }
 
-        impl From<$name> for $repr {
-            fn from(value: $name) -> $repr {
-                value as $repr
+        impl From<$name> for c_int {
+            fn from(value: $name) -> c_int {
+                value as c_int
             }
         }
     }