www/varnish-libvmod-fileserver: fix build on ARM / POWER

Fix build with unsigned char instead signed char:
133 |         iface.ifr_name[i] = c as i8;
    |         -----------------   ^^^^^^^ expected `u8`, found `i8`
This commit is contained in:
Piotr Kubaj 2023-01-08 12:41:25 +01:00
parent 0d25d9117f
commit 7eb89cf86e
6 changed files with 169 additions and 0 deletions

View File

@ -0,0 +1,14 @@
--- cargo-crates/varnish-0.0.12/src/vcl/convert.rs.orig 2023-01-08 01:32:37 UTC
+++ cargo-crates/varnish-0.0.12/src/vcl/convert.rs
@@ -139,9 +139,9 @@ impl IntoVCL<VCL_STRING> for &[u8] {
// try to save some work if the buffer is already in the workspace
// and if it's followed by a null byte
if unsafe { varnish_sys::WS_Allocated(ws.raw, self.as_ptr() as *const c_void, self.len() as i64 + 1) == 1 && *self.as_ptr().add(self.len()) == b'\0' } {
- Ok(self.as_ptr() as *const i8)
+ Ok(self.as_ptr() as *const c_char)
} else {
- Ok(ws.copy_bytes_with_null(&self)?.as_ptr() as *const i8)
+ Ok(ws.copy_bytes_with_null(&self)?.as_ptr() as *const c_char)
}
}
}

View File

@ -0,0 +1,38 @@
--- cargo-crates/varnish-0.0.12/src/vcl/ctx.rs.orig 2023-01-08 01:41:36 UTC
+++ cargo-crates/varnish-0.0.12/src/vcl/ctx.rs
@@ -4,6 +4,7 @@ use std::os::raw::{c_uint, c_void};
use crate::vcl::http::HTTP;
use crate::vcl::ws::{TestWS, WS};
+use std::os::raw::c_char;
use std::ptr;
use varnish_sys::{
busyobj, req, sess, vrt_ctx, vsb, vsl_log, ws, VSL_tag_e_SLT_Debug, VSL_tag_e_SLT_Error,
@@ -103,7 +104,7 @@ impl<'a> Ctx<'a> {
// not great, we have to copy the string to add a null character
let c_cstring = CString::new(msg).unwrap();
unsafe {
- VRT_fail(self.raw, "%s\0".as_ptr() as *const i8, c_cstring.as_ptr());
+ VRT_fail(self.raw, "%s\0".as_ptr() as *const c_char, c_cstring.as_ptr());
}
0
}
@@ -116,8 +117,8 @@ impl<'a> Ctx<'a> {
log(logtag, msg);
} else {
let t = varnish_sys::txt {
- b: msg.as_ptr() as *const i8,
- e: msg.as_ptr().add(msg.len()) as *const i8,
+ b: msg.as_ptr() as *const c_char,
+ e: msg.as_ptr().add(msg.len()) as *const c_char,
};
varnish_sys::VSLbt(p.vsl, logtag.into_u32(), t);
@@ -245,6 +246,6 @@ impl Event {
pub fn log(logtag: LogTag, msg: &str) {
unsafe {
let c_cstring = CString::new(msg).unwrap();
- varnish_sys::VSL(logtag.into_u32(), 0, b"%s\0".as_ptr() as *const i8, c_cstring.as_ptr() as *const u8);
+ varnish_sys::VSL(logtag.into_u32(), 0, b"%s\0".as_ptr() as *const c_char, c_cstring.as_ptr() as *const u8);
}
}

View File

@ -0,0 +1,23 @@
--- cargo-crates/varnish-0.0.12/src/vcl/http.rs.orig 2023-01-08 02:38:57 UTC
+++ cargo-crates/varnish-0.0.12/src/vcl/http.rs
@@ -12,7 +12,7 @@
//! this [issue](https://github.com/gquintard/varnish-rs/issues/4).
#![allow(clippy::not_unsafe_ptr_arg_deref)]
-use std::os::raw::c_uint;
+use std::os::raw::{c_char, c_uint};
use std::slice::{from_raw_parts, from_raw_parts_mut};
use std::str::from_utf8;
@@ -53,9 +53,9 @@ impl<'a> HTTP<'a> {
let hdr_buf = ws.copy_bytes_with_null(&value)?;
unsafe {
let mut hd = self.raw.hd.offset(idx as isize);
- (*hd).b = hdr_buf.as_ptr() as *const i8;
+ (*hd).b = hdr_buf.as_ptr() as *const c_char;
/* -1 accounts for the null character */
- (*hd).e = hdr_buf.as_ptr().add(hdr_buf.len() - 1) as *const i8;
+ (*hd).e = hdr_buf.as_ptr().add(hdr_buf.len() - 1) as *const c_char;
let hdf = self.raw.hdf.offset(idx as isize);
*hdf = 0;
}

View File

@ -0,0 +1,28 @@
--- cargo-crates/varnish-0.0.12/src/vcl/processor.rs.orig 2023-01-08 02:45:31 UTC
+++ cargo-crates/varnish-0.0.12/src/vcl/processor.rs
@@ -5,6 +5,7 @@
//! *Note:* The rust wrapper here is pretty thin and the vmod writer will most probably need to have to
//! deal with the raw Varnish internals.
+use std::os::raw::c_char;
use std::os::raw::c_int;
use std::os::raw::c_void;
use std::ptr;
@@ -129,7 +130,7 @@ pub unsafe extern "C" fn gen_vdp_push<T: VDP>(
/// Create a `varnish_sys::vdp` that can be fed to `varnish_sys::VRT_AddVDP`
pub fn new_vdp<T: VDP>() -> varnish_sys::vdp {
varnish_sys::vdp {
- name: T::name().as_ptr() as *const i8,
+ name: T::name().as_ptr() as *const c_char,
init: Some(gen_vdp_init::<T>),
bytes: Some(gen_vdp_push::<T>),
fini: Some(gen_vdp_fini::<T>),
@@ -246,7 +247,7 @@ pub unsafe extern "C" fn wrap_vfp_fini<T: VFP>(ctxp: *
/// Create a `varnish_sys::vfp` that can be fed to `varnish_sys::VRT_AddVFP`
pub fn new_vfp<T: VFP>() -> varnish_sys::vfp {
varnish_sys::vfp {
- name: T::name().as_ptr() as *const i8,
+ name: T::name().as_ptr() as *const c_char,
init: Some(wrap_vfp_init::<T>),
pull: Some(wrap_vfp_pull::<T>),
fini: Some(wrap_vfp_fini::<T>),

View File

@ -0,0 +1,28 @@
--- cargo-crates/varnish-0.0.12/src/vcl/ws.rs.orig 2023-01-08 02:53:56 UTC
+++ cargo-crates/varnish-0.0.12/src/vcl/ws.rs
@@ -10,6 +10,7 @@
//! **Note:** unless you know what you are doing, you should probably just use the automatic type
//! conversion provided by [`crate::vcl::convert`], or store things in
//! [`crate::vcl::vpriv::VPriv`].
+use std::os::raw::c_char;
use std::ffi::c_void;
use std::ptr;
use std::slice::from_raw_parts_mut;
@@ -213,7 +214,7 @@ impl<'a> Drop for ReservedBuf<'a> {
pub struct TestWS {
c_ws: varnish_sys::ws,
#[allow(dead_code)]
- space: Vec<i8>,
+ space: Vec<c_char>,
}
impl TestWS {
@@ -229,7 +230,7 @@ impl TestWS {
TestWS {
c_ws: varnish_sys::ws {
magic: varnish_sys::WS_MAGIC,
- id: ['t' as i8, 's' as i8, 't' as i8, '\0' as i8],
+ id: ['t' as c_char, 's' as c_char, 't' as c_char, '\0' as c_char],
s,
f: s,
r: ptr::null_mut(),

View File

@ -0,0 +1,38 @@
--- src/lib.rs.orig 2023-01-08 03:03:24 UTC
+++ src/lib.rs
@@ -5,7 +5,7 @@ use std::collections::HashMap;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::io::{BufRead, BufReader, Read};
-use std::os::raw::{c_uint, c_void};
+use std::os::raw::{c_char, c_uint, c_void};
use std::os::unix::fs::MetadataExt;
use std::ptr;
@@ -113,7 +113,7 @@ impl root {
ctx.raw,
&METHODS.methods,
info_ptr as *mut std::ffi::c_void,
- format!("{}\0", vcl_name).as_ptr() as *const i8,
+ format!("{}\0", vcl_name).as_ptr() as *const c_char,
)
};
@@ -170,7 +170,7 @@ struct VfpWrapper {
}
static FILE_VFP: VfpWrapper = VfpWrapper {
vfp: varnish_sys::vfp {
- name: "fileserver\0".as_ptr() as *const i8,
+ name: "fileserver\0".as_ptr() as *const c_char,
init: None,
pull: Some(varnish::vcl::processor::wrap_vfp_pull::<BackendResp>),
fini: Some(varnish::vcl::processor::wrap_vfp_fini::<BackendResp>),
@@ -233,7 +233,7 @@ unsafe extern "C" fn be_gethdrs(
);
if (*bo.req).req_body_status != varnish_sys::BS_CACHED.as_ptr() {
- bo.no_retry = "req.body not cached\0".as_ptr() as *const i8;
+ bo.no_retry = "req.body not cached\0".as_ptr() as *const c_char;
}
if (*bo.req).req_body_status == varnish_sys::BS_ERROR.as_ptr() {