I need to copy curr_task->pid
, a pid_t
in kernel space, to a structure's field in user space that has space for a long. Since this is a widening conversion, I'm not expecting any issues.
However, I'm getting an annoying compiler warning (copy_long_to_user
is for all intents and purposes the same as copy_to_user
):
cs300/process_ancestors.c:31:3: warning: passing argument 2 of ‘copy_long_to_user’ from incompatible pointer type [enabled by default]
if(copy_long_to_user(&info_array[num_filled_kernel].pid, &curr_task->pid)) {
^
cs300/process_ancestors.c:9:5: note: expected ‘long int *’ but argument is of type ‘pid_t *’
Is this warning something I can safely ignore (will the compiler do the cast for me)? If I need to cast curr_task->pid
to a long explicitly, how can I do that in the context of using copy_to_user
? My guess would be that it's something like:(copy_long_to_user(&info_array[num_filled_kernel].pid, &((long)curr_task->pid)))