On Thu, May 19, 2022 at 9:09 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > > On Thu, May 19, 2022 at 08:55:05PM +0800, Muchun Song wrote: > > @@ -428,6 +428,8 @@ static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp, > > int write, void *data) > > { > > if (write) { > > + if (*negp || (*lvalp != 0 && *lvalp != 1)) > > + return -EINVAL; > > *(bool *)valp = *lvalp; > > } else { > > int val = *(bool *)valp; > > Is this the right approach? Or should we do as C does and interpret > writing non-zero as true? ie: All right. We could obey the C rule here. > > *(bool *)valp = (bool)*lvalp; > > (is that cast needed? It wouldn't be if it were an int, but bool is a > bit weird) > If the cast is weird. How about: *(bool *)valp = *lvalp ? true : false; Thanks.