Linux kernel staging patches
 help / color / mirror / Atom feed
From: Ian Abbott <abbotti@mev.co.uk>
To: Spencer Olson <olsonse@umich.edu>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-staging@lists.linux.dev,
	H Hartley Sweeten <hsweeten@visionengravers.com>
Subject: Re: [PATCH 0/5] staging: comedi: tests: Fix various issues
Date: Wed, 14 Apr 2021 18:05:21 +0100	[thread overview]
Message-ID: <5caafc6f-74fb-ec1e-cdd9-0f5b450bade8@mev.co.uk> (raw)
In-Reply-To: <CAOx9PegwL50fZfxG3D8ePEqcyPNJHWeF=T65ubv2SFoW2Yq2ow@mail.gmail.com>

On 14/04/2021 15:29, Spencer Olson wrote:
> On Wed, Apr 14, 2021 at 6:34 AM Ian Abbott <abbotti@mev.co.uk> 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).
>>
> 
> Good catch.  Based on the error message that for the unittest failure,
> I would agree that my intention had been to test when src is indeed <
> NI_NAMES_BASE so that we could test for a bad direct register value.
> It does indeed look like sending in 0 for the src would have worked,
> since the first row in private table RV in ni_routes_test.c (the row
> for destination passed in as "O(0)") does not have a "register value"
> equal to 0.  It would be nice to compile and test this code though,
> but I can't do it for another couple of weeks.
> 
> Actually, looking a little further, I don't think that src=0 will work
> here.  There is another argument for ni_get_reg_value_roffs,
> direct_reg_offset, that gets added to src before sending to
> route_register_is_valid.  I think this was provided to fix an offset
> mismatch that was in the original approach to handling signal routing
> values (i.e. to provide backwards compatibility).  But, I do think
> that value greater or equal to 9 will actually work.

Since that unittest() is calling ni_get_reg_value_roffs() with src=-1
and direct_reg_offset=1, and ni_get_reg_value_roffs() adds
direct_reg_offset to src if src < NI_NAMES_BASE, would setting src=0,
direct_reg_offset=0 work? I.e., like this:

        unittest(ni_get_reg_value_roffs(0, O(0), T, 0) == -1,
                 "check bad direct trigger arg for first reg->dest
w/offs\n");

-- 
-=( Ian Abbott <abbotti@mev.co.uk> || 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 )=-

  reply	other threads:[~2021-04-14 17:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 14:01 [PATCH 0/5] staging: comedi: tests: Fix various issues Ian Abbott
2021-04-07 14:01 ` [PATCH 1/5] staging: comedi: tests: ni_routes_test: Fix compilation error Ian Abbott
2021-04-07 14:01 ` [PATCH 2/5] staging: comedi: tests: ni_routes_test: Put complex values in parentheses Ian Abbott
2021-04-07 14:01 ` [PATCH 3/5] staging: comedi: tests: ni_routes_test: Avoid CamelCase: <RVi> Ian Abbott
2021-04-07 15:23   ` Spencer Olson
2021-04-07 14:01 ` [PATCH 4/5] staging: comedi: tests: ni_routes_test: Lines should not end with a '(' Ian Abbott
2021-04-07 14:01 ` [PATCH 5/5] staging: comedi: tests: Correct unittest_fptr Ian Abbott
2021-04-07 15:10 ` [PATCH 0/5] staging: comedi: tests: Fix various issues Greg Kroah-Hartman
2021-04-07 15:39   ` Ian Abbott
2021-04-07 15:48     ` Spencer Olson
2021-04-07 16:16       ` Ian Abbott
2021-04-07 17:26     ` Greg Kroah-Hartman
2021-04-07 18:20       ` Ian Abbott
2021-04-08  7:27         ` Greg Kroah-Hartman
2021-04-14 10:09       ` Dan Carpenter
2021-04-14 10:40         ` Ian Abbott
2021-04-14 12:34         ` Ian Abbott
2021-04-14 13:28           ` Dan Carpenter
2021-04-14 13:57             ` Spencer Olson
2021-04-14 17:24             ` Ian Abbott
2021-04-14 14:29           ` Spencer Olson
2021-04-14 17:05             ` Ian Abbott [this message]
2021-04-15  9:57           ` Ian Abbott
2021-04-14 12:40         ` Ian Abbott
2021-04-14 13:12           ` Greg Kroah-Hartman
2021-04-14 13:30           ` Dan Carpenter
2021-04-07 15:43 ` Spencer Olson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5caafc6f-74fb-ec1e-cdd9-0f5b450bade8@mev.co.uk \
    --to=abbotti@mev.co.uk \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hsweeten@visionengravers.com \
    --cc=linux-staging@lists.linux.dev \
    --cc=olsonse@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).