On Wed, Feb 03, 2016 at 04:25:44AM +0800, Christopher Li wrote: > On Wed, Jan 6, 2016 at 12:25 AM, Luc Van Oostenryck > <luc.vanoostenryck@xxxxxxxxx> wrote: > > With the following code: > > typedef unsigned long __nocast cputime_t; > > > > void task_cputime_adjusted(cputime_t *); > > > > void current_task_runtime_100ns(void) > > { > > cputime_t utime; > > > > task_cputime_adjusted(&utime); > > } > > > > sparse emits the following message: > > x.c:16:32: warning: incorrect type in argument 1 (different modifiers) > > x.c:16:32: expected unsigned long [nocast] [usertype] *<noident> > > x.c:16:32: got unsigned long *<noident> > > x.c:16:32: warning: implicit cast to nocast type > > > > In other words, when taking the address of 'utime', sparse drops the 'nocast' > > modifier and then complains that task_cputime_adjusted() is not given a > > 'nocast' pointer as expected ... > > I think there is a bug some where else. In the above example, > "cputime_t *" and "&utime" should have the same type regardless > pointer inherent the nocast attribute or not. I haven't fully understand > where the nocast attribute get dropped. The nocast mod is dropped and lost in the function create_pointer(). In the example above, "cputime_t *" has type : unsigned long [nocast] [usertype] * while &utime is just: unsigned long * So, for sparse and its extended notion of type, the type we get when taking the address of a [variable of some] type X is not the same as directly using a pointer to the type X. Which is very fine, just that MOD_NOCAST is dropped while the example shows that it should not. OTOH, MOD_STORAGE is kept but I think should be dropped; but that's another story. Regards, Luc -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html