Re: How to choose format specifier for boolean variables in Linux kernel?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 24, 2021 at 10:27 PM 慕冬亮 <mudongliangabcd@xxxxxxxxx> wrote:
>
> On Mon, May 24, 2021 at 10:22 PM Fox Chen <foxhlchen@xxxxxxxxx> wrote:
> >
> > On Mon, May 24, 2021 at 6:51 PM 慕冬亮 <mudongliangabcd@xxxxxxxxx> wrote:
> > >
> > > Hi all,
> > >
> > > how do I choose format specifier for boolean variables in Linux
> > > kernel? For example,
> > >
> > > bool bup;
> > > pr_alert("%XXX", bup);
> > >
> > > What should "XXX" be in the Linux kernel?
> > >
> > > --
> > > My best regards to you.
> > >
> > >      No System Is Safe!
> > >      Dongliang Mu
> > >
> > > _______________________________________________
> > > Kernelnewbies mailing list
> > > Kernelnewbies@xxxxxxxxxxxxxxxxx
> > > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >
> > Check commit 6e21828743 ("Generic boolean")
> > IIUC bool is defined as Bool_. You can treat it as an integer with the
> > value 0 or 1.
>
> You mean I can directly print boolean variable with "%d"?
>
yes, or if you want it to be more readable, you can do
pr_alert("%s", bup ? "true":"false");

> >
> >
> > thanks,
> > fox

fox

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux