lkml.org 
[lkml]   [2006]   [Jul]   [12]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
FromKeith Owens <>
SubjectRe: sparse annotation question
DateWed, 12 Jul 2006 16:42:44 +1000
David Miller (on Tue, 11 Jul 2006 23:14:09 -0700 (PDT)) wrote:
>From: Keith Owens <kaos@ocs.com.au>
>Date: Wed, 12 Jul 2006 15:47:03 +1000
>
>> func (long regno, unsigned long *contents)
>> {
>> 	unsigned long i, *bsp;
>> 	mm_segment_t old_fs;
>> 	bsp = <expression involving only kernel variables>;
>> 	old_fs = set_fs(KERNEL_DS);
>> 	for (i = 0; i < (regno - 32); ++i)
>> 		bsp = ia64_rse_skip_regs(bsp, 1);
>> 	put_user(*contents, bsp);
>> 	set_fs(old_fs);
>> }
>> 
>> sparse is complaining that the second parameter to put_user() is not
>> marked as __user.  How do I tell sparse to ignore this case?  Marking
>> bsp as __user does not work, sparse then complains about incorrect type
>> in assignment (different address spaces).
>
>Since, in this case, you "know what you are doing" you can force the
>matter by using the __force keyword as well as __user.

I tried various combinations of __force, but kept getting this:

warning: incorrect type in argument 1 (different address spaces)
   expected unsigned long *addr
   got unsigned long [noderef] [force] *[addressable] bsp<asn:1>

What finally worked was

 	unsigned long i, *bsp, __user *ubsp;
	...
	ubsp = (unsigned long __user *) bsp;
	put_user(*contents, ubsp);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-07-12 08:45    [from the cache]
©2003-2008