* How to choose format specifier for boolean variables in Linux kernel?
@ 2021-05-24 10:50 慕冬亮
2021-05-24 14:22 ` Fox Chen
2021-05-24 14:56 ` Aruna Hewapathirane
0 siblings, 2 replies; 7+ messages in thread
From: 慕冬亮 @ 2021-05-24 10:50 UTC (permalink / raw)
To: kernelnewbies
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@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to choose format specifier for boolean variables in Linux kernel?
2021-05-24 10:50 How to choose format specifier for boolean variables in Linux kernel? 慕冬亮
@ 2021-05-24 14:22 ` Fox Chen
2021-05-24 14:27 ` 慕冬亮
2021-05-24 14:56 ` Aruna Hewapathirane
1 sibling, 1 reply; 7+ messages in thread
From: Fox Chen @ 2021-05-24 14:22 UTC (permalink / raw)
To: 慕冬亮; +Cc: kernelnewbies
On Mon, May 24, 2021 at 6:51 PM 慕冬亮 <mudongliangabcd@gmail.com> 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@kernelnewbies.org
> 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.
thanks,
fox
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to choose format specifier for boolean variables in Linux kernel?
2021-05-24 14:22 ` Fox Chen
@ 2021-05-24 14:27 ` 慕冬亮
2021-05-24 14:29 ` 慕冬亮
2021-05-24 14:38 ` Fox Chen
0 siblings, 2 replies; 7+ messages in thread
From: 慕冬亮 @ 2021-05-24 14:27 UTC (permalink / raw)
To: Fox Chen; +Cc: kernelnewbies
On Mon, May 24, 2021 at 10:22 PM Fox Chen <foxhlchen@gmail.com> wrote:
>
> On Mon, May 24, 2021 at 6:51 PM 慕冬亮 <mudongliangabcd@gmail.com> 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@kernelnewbies.org
> > 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"?
>
>
> thanks,
> fox
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to choose format specifier for boolean variables in Linux kernel?
2021-05-24 14:27 ` 慕冬亮
@ 2021-05-24 14:29 ` 慕冬亮
2021-05-24 14:38 ` Fox Chen
1 sibling, 0 replies; 7+ messages in thread
From: 慕冬亮 @ 2021-05-24 14:29 UTC (permalink / raw)
To: Fox Chen; +Cc: kernelnewbies
On Mon, May 24, 2021 at 10:27 PM 慕冬亮 <mudongliangabcd@gmail.com> wrote:
>
> On Mon, May 24, 2021 at 10:22 PM Fox Chen <foxhlchen@gmail.com> wrote:
> >
> > On Mon, May 24, 2021 at 6:51 PM 慕冬亮 <mudongliangabcd@gmail.com> 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@kernelnewbies.org
> > > 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"?
>
For C enumeration, it seems right.
> >
> >
> > thanks,
> > fox
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to choose format specifier for boolean variables in Linux kernel?
2021-05-24 14:27 ` 慕冬亮
2021-05-24 14:29 ` 慕冬亮
@ 2021-05-24 14:38 ` Fox Chen
2021-05-24 14:39 ` 慕冬亮
1 sibling, 1 reply; 7+ messages in thread
From: Fox Chen @ 2021-05-24 14:38 UTC (permalink / raw)
To: 慕冬亮; +Cc: kernelnewbies
On Mon, May 24, 2021 at 10:27 PM 慕冬亮 <mudongliangabcd@gmail.com> wrote:
>
> On Mon, May 24, 2021 at 10:22 PM Fox Chen <foxhlchen@gmail.com> wrote:
> >
> > On Mon, May 24, 2021 at 6:51 PM 慕冬亮 <mudongliangabcd@gmail.com> 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@kernelnewbies.org
> > > 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@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to choose format specifier for boolean variables in Linux kernel?
2021-05-24 14:38 ` Fox Chen
@ 2021-05-24 14:39 ` 慕冬亮
0 siblings, 0 replies; 7+ messages in thread
From: 慕冬亮 @ 2021-05-24 14:39 UTC (permalink / raw)
To: Fox Chen; +Cc: kernelnewbies
On Mon, May 24, 2021 at 10:39 PM Fox Chen <foxhlchen@gmail.com> wrote:
>
> On Mon, May 24, 2021 at 10:27 PM 慕冬亮 <mudongliangabcd@gmail.com> wrote:
> >
> > On Mon, May 24, 2021 at 10:22 PM Fox Chen <foxhlchen@gmail.com> wrote:
> > >
> > > On Mon, May 24, 2021 at 6:51 PM 慕冬亮 <mudongliangabcd@gmail.com> 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@kernelnewbies.org
> > > > 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. This is really helpful.
> > >
> > >
> > > thanks,
> > > fox
>
> fox
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to choose format specifier for boolean variables in Linux kernel?
2021-05-24 10:50 How to choose format specifier for boolean variables in Linux kernel? 慕冬亮
2021-05-24 14:22 ` Fox Chen
@ 2021-05-24 14:56 ` Aruna Hewapathirane
1 sibling, 0 replies; 7+ messages in thread
From: Aruna Hewapathirane @ 2021-05-24 14:56 UTC (permalink / raw)
To: 慕冬亮; +Cc: kernelnewbies
[-- Attachment #1.1: Type: text/plain, Size: 450 bytes --]
On Mon, May 24, 2021 at 6:51 AM 慕冬亮 <mudongliangabcd@gmail.com> 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?
>
> Dongliang Mu
>
Please go through this. Hope it will help.
https://stackoverflow.com/questions/17307275/what-is-the-printf-format-specifier-for-bool
Aruna
[-- Attachment #1.2: Type: text/html, Size: 948 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-05-24 14:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24 10:50 How to choose format specifier for boolean variables in Linux kernel? 慕冬亮
2021-05-24 14:22 ` Fox Chen
2021-05-24 14:27 ` 慕冬亮
2021-05-24 14:29 ` 慕冬亮
2021-05-24 14:38 ` Fox Chen
2021-05-24 14:39 ` 慕冬亮
2021-05-24 14:56 ` Aruna Hewapathirane
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.