On Fri, Sep 4, 2020 at 9:40 AM Bhindhiya Raja <bhindhiy...@tataelxsi.co.in.invalid> wrote: > > Hello Nathan, > > Thank you for your response. We have submitted 2 separate PRs as recommended > by you to resolve warnings 6 (#1695) and 8 (#1702). > > About warnings 1 to 4, we understand that casting away the 'volatile' type > qualifier of a variable should be avoided if possible. Can we consider > modifying the prototype of the function up_copystate() in up_internal.h file, > from: > void up_copystate(uint32_t *dest, uint32_t *src); > to: > void up_copystate(uint32_t *dest, volatile uint32_t *src); > in order to resolve this warning. > > We have tried the above fix in our local repository and checked build. > We found that warnings 1 to 4 are resolved, however, it generates a new > warning in file: > arch/renesas/src/rx65n/rx65n_copystate.c: passing argument 2 of > ‘up_copystate’ discards ‘volatile’ qualifier from pointer target type > memcpy(dest, src, XCPTCONTEXT_SIZE); > > expected ‘const void *’ but argument is of type ‘volatile uint32_t *’ > FAR void *memcpy(FAR void *dest, FAR const void *src, size_t n); > > This can be resolved by typecasting the variables when calling memcpy() alone. > > As these files are common to other Renesas architectures as well, please > confirm if the above modifications are okay.
Hello Bhindhiya, I am not sure what is the best choice here. I looked through NuttX sources and I did not see any up_copystate() (for any arch) that had volatile qualifiers. That said, looking at the call to up_copystate() in up_unblock_task(), g_current_regs is indeed volatile (for good reasons), so I wonder if we should propagate that as far as possible, until the memcpy(), like you're suggesting, or, alternatively, if it is safe to discard volatile like is being done already, because we are switching tasks. I need to think about this some more. Maybe Greg will share some of his wisdom with us. :-) Nathan