@@ -196,13 +196,13 @@ impl<'a, T> ConfigBuilder<'a, T> {
196196 where F : FnMut ( & Config < T > , & [ u8 ] ) -> ( Unknown < T > , u32 ) ,
197197 F : ' a {
198198 // yeah.. libipt doesnt handle this -_-
199- if buf. len ( ) < 1 { return Err (
199+ if buf. is_empty ( ) { return Err (
200200 PtError :: new ( PtErrorCode :: Invalid , "buffer cant be empty!" )
201201 ) }
202202 let mut cfg: pt_config = unsafe { mem:: zeroed ( ) } ;
203203 cfg. size = mem:: size_of :: < pt_config > ( ) ;
204204 cfg. begin = buf. as_mut_ptr ( ) ;
205- cfg. end = unsafe { buf. as_mut_ptr ( ) . offset ( buf. len ( ) as isize ) } ;
205+ cfg. end = unsafe { buf. as_mut_ptr ( ) . add ( buf. len ( ) ) } ;
206206 cfg. decode . callback = Some ( decode_callback :: < F , T > ) ;
207207 cfg. decode . context = & mut cb as * mut _ as * mut c_void ;
208208 Ok ( ConfigBuilder :: < T > ( cfg, PhantomData ) )
@@ -252,13 +252,13 @@ impl<'a> ConfigBuilder<'a, ()> {
252252 /// use the `with_callback` function
253253 /// returns `Invalid` when buf is empty
254254 pub fn new ( buf : & ' a mut [ u8 ] ) -> Result < ConfigBuilder < ' a , ( ) > , PtError > {
255- if buf. len ( ) < 1 { return Err (
255+ if buf. is_empty ( ) { return Err (
256256 PtError :: new ( PtErrorCode :: Invalid , "buffer cant be empty!" )
257257 ) }
258258 let mut cfg: pt_config = unsafe { mem:: zeroed ( ) } ;
259259 cfg. size = mem:: size_of :: < pt_config > ( ) ;
260260 cfg. begin = buf. as_mut_ptr ( ) ;
261- cfg. end = unsafe { buf. as_mut_ptr ( ) . offset ( buf. len ( ) as isize ) } ;
261+ cfg. end = unsafe { buf. as_mut_ptr ( ) . add ( buf. len ( ) ) } ;
262262 Ok ( ConfigBuilder :: < ( ) > ( cfg, PhantomData ) )
263263 }
264264}
0 commit comments