sysconf returns a long which is an i32 on ILP32 architectures.
Add a cast which is a noop on LP64 architectures; the overflow of
an u32 in this check can't happen on ILP32 anyway.

Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/bat/Makefile,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile
--- Makefile    11 Sep 2021 07:36:14 -0000      1.5
+++ Makefile    13 Sep 2021 20:11:34 -0000
@@ -1,19 +1,11 @@
 # $OpenBSD: Makefile,v 1.5 2021/09/11 07:36:14 semarie Exp $
 
-# building sys-info fails
-# error[E0308]: mismatched types
-#    --> 
/pobj/bat-0.18.2/bat-0.18.2/modcargo-crates/sys-info-0.9.0/lib.rs:542:29
-#     |
-# 542 |         if ret < 1 || ret > std::u32::MAX as i64 {
-#     |                             ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found 
`i64`
-
-ONLY_FOR_ARCHS =       ${LP64_ARCHS}
-
 COMMENT =              cat(1) clone with wings
 
 GH_ACCOUNT =           sharkdp
 GH_PROJECT =           bat
 GH_TAGNAME =           v0.18.3
+REVISION =             0
 
 CATEGORIES =           sysutils
 
@@ -29,6 +21,7 @@ WANTLIB += c c++abi git2 m onig pthread
 
 CONFIGURE_STYLE =      cargo
 SEPARATE_BUILD =       Yes
+PATCHORIG =            .openbsd.orig
 
 LIB_DEPENDS +=         devel/libgit2/libgit2 \
                        textproc/oniguruma
Index: patches/patch-modcargo-crates_sys-info-0_9_0_lib_rs
===================================================================
RCS file: patches/patch-modcargo-crates_sys-info-0_9_0_lib_rs
diff -N patches/patch-modcargo-crates_sys-info-0_9_0_lib_rs
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-modcargo-crates_sys-info-0_9_0_lib_rs 13 Sep 2021 20:11:34 
-0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+Fix build on ILP32 architectures.
+
+Index: modcargo-crates/sys-info-0.9.0/lib.rs
+--- modcargo-crates/sys-info-0.9.0/lib.rs.orig
++++ modcargo-crates/sys-info-0.9.0/lib.rs
+@@ -539,7 +539,7 @@ pub fn cpu_num() -> Result<u32, Error> {
+     #[cfg(any(target_os = "solaris", target_os = "illumos", target_os = 
"freebsd", target_os = "openbsd", target_os = "netbsd"))]
+     {
+         let ret = unsafe { libc::sysconf(libc::_SC_NPROCESSORS_ONLN) };
+-        if ret < 1 || ret > std::u32::MAX as i64 {
++        if ret < 1 || ret as i64 > std::u32::MAX as i64 {
+             Err(Error::IO(io::Error::last_os_error()))
+         } else {
+             Ok(ret as u32)

Reply via email to