Re: [PATCH 0/5] staging: comedi: tests: Fix various issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 14, 2021 at 01:34:23PM +0100, Ian Abbott wrote:
> > drivers/staging/comedi/drivers/ni_routes.c:61 ni_find_route_values() warn: 'device_family' sometimes too small '8,11' size = 30
> >      59          for (i = 0; ni_all_route_values[i]; ++i) {
> >      60                  if (memcmp(ni_all_route_values[i]->family, device_family,
> >                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >      61                             strnlen(device_family, 30)) == 0) {
> >                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
> > This whole memcmp() is very strange.  Why not just use:
> > 
> > 	if (strncmp(ni_all_route_values[i]->family, device_family, 30) == 0)
> 
> I think even a simple strcmp() would do as well because all the device
> family strings and board name strings are null terminated.  I don't know why
> the magic number 30 is used here!
> 
> The above applies similarly to ni_find_valid_routes() too.
> 

I was thinking maybe ni_all_route_values[i]->family has an additional
string on the end.  For example, it could end in "_bar" and we want
->family "foo_bar" to match with device_family "foo"?

regards,
dan carpenter





[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux