[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: Why preferring smallint to bool in some places?
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2017-01-26 18:00:48
Message-ID: CAK1hOcPQJV=4ut9T=yN8d7f0jOVTNZioF_zSntB-Q_V8cfxgvg () mail ! gmail ! com
[Download RAW message or body]

On Thu, Jan 26, 2017 at 6:25 AM, Kang-Che Sung <explorer09@gmail.com> wrote:
> May I ask some little code questions? I have been reading some of the
> changes in busybox and I don't understand the use of type "smallint" in
> this code
>
> 9a64c3337cc0a5e84e9ad457eeb1d475c311e9fc "ls: convert DISP_DIRNAME to
> a bool variable"
>
> ls.c
>
>     @@ -330,7 +326,7 @@ struct globals {
>      # define G_show_color 0
>      #endif
>       smallint exit_code;
>     - unsigned all_fmt;
>     + smallint show_dirname;
>      #if ENABLE_FEATURE_LS_WIDTH
>       unsigned terminal_width;
>      # define G_terminal_width (G.terminal_width)
>
> Here it seems that this "show_dirname" variable is supposed to hold a
> boolean value, but why not declare it with the type bool? What's the
> rationale behind preferring smallint?

size of bool is controlled by compiler.
If on some arch people who decide on its ABI would decide that int-sized
bools are somewhat faster and settle for that,
bbox will have to use that even if we'd prefer "smaller"
(if performance hit is not too bad).

smallints are ours. bbox defines their sizes.
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic