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

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

 



On 14/04/2021 13:34, Ian Abbott wrote:
On 14/04/2021 11:09, Dan Carpenter wrote:
The test_ni_get_reg_value() function calls
    unittest(ni_get_reg_value_roffs(-1, O(0), T, 1) == -1,
         "check bad direct trigger arg for first reg->dest w/offs\n");
The -1 is type promoted to a high positive value so src is greater than
NI_NAMES_BASE.  It's not clear that that was intentional.
drivers/staging/comedi/drivers/tests/../ni_routes.h:269 ni_get_reg_value_roffs() warn: 'src' possible negative type promoted to high

I agree that it appears that ni_get_reg_value_roffs() will be returning -1 as expected, but for the wrong reason.  I think the intention was for ni_get_reg_value_roffs() to call route_register_is_valid() with src=0 in this case, but it actually calls ni_route_to_register() with src=-1 (because -1 gets converted to 0xffffffff in the test `if (src < NI_NAMES_BASE)` where NI_NAMES_BASE is defined as 0x8000u).

Since Spencer agrees that the existing behavior was unintentional, I think the least disruptive fix would be change `src < NI_NAMES_BASE` to `src < (int)NI_NAMES_BASE` in `ni_get_reg_value_roffs()` in ".../comedi/drivers/ni_routes.h".

Either that, or change the interface to use unsigned `src` and `direct_reg_offset` values. The negative values only seem to be used by the "ni_routes_test" unit testing module.

--
-=( Ian Abbott <abbotti@xxxxxxxxx> || MEV Ltd. is a company  )=-
-=( registered in England & Wales.  Regd. number: 02862268.  )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-




[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