On 16-01-23, 22:39, Bartosz Golaszewski wrote: > On Mon, Jan 16, 2023 at 6:52 AM Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote: > > > + let mut offsets = vec![0; num_lines as usize]; > > > + > > > + // SAFETY: gpiod_line_config is guaranteed to be valid here. > > > + unsafe { gpiod::gpiod_line_config_get_configured_offsets(self.config, > > > + offsets.as_mut_ptr(), > > > + num_lines) }; > > > > Can the returned value be < num_lines here ? > > > > Ah, of course it can. Need to add a test case for that. How do I set > the size of offsets to whatever this function returns? Instead of any heavy operation, you can rather do something like this: let num = unsafe { gpiod::gpiod_line_config_get_configured_offsets(self.config, offsets.as_mut_ptr(), num_lines) }; for offset in offsets[0..num] { ... } -- viresh