Twisted use of * const * after variable name in Linux kernel

Can someone please explain what is actually defined in the following code and also what const is at the end? Is a variable named __user

and __argv

type pointer __user

?

const char __user *const __user *__argv

      

I am familiar with the placement possibilities const

(making the pointer / data non-indexable), but I never thought about this possibility.

Snippet from this function declaration in the core:

1593 int do_execve(const char *filename,
1594         const char __user *const __user *__argv,
1595         const char __user *const __user *__envp,
1596         struct pt_regs *regs)

      

EDIT: I probably wouldn't have asked if I knew about a macro earlier __user

. However, this is not exactly a duplicate of this , because the actual type of a particular variable is not discussed there.

+3


source to share


2 answers


In fact, it __user

is a macro that provides some attributes (more on that here ). So the variable is called __argv

which has a pointer to pointer to const for const char.



+5


source


const T *p

and T const *p

declare p

as a pointer to const T

.

T * const p

declares p

as a pointer const

to T

.



const T * const p

and T const * const p

are declared p

as a pointer const

to const T

.

0


source







All Articles