From: Goffredo Baroncelli <kreijack@gmail.com>
To: Zach Brown <zab@redhat.com>
Cc: kreijack@inwind.it, Eric Sandeen <sandeen@redhat.com>,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/8] Add some helpers to manage the strings allocation/deallocation.
Date: Mon, 25 Feb 2013 22:00:28 +0100 [thread overview]
Message-ID: <512BD0EC.8040707@gmail.com> (raw)
In-Reply-To: <20130225201950.GC1658@lenny.home.zabbo.net>
On 02/25/2013 09:19 PM, Zach Brown wrote:
>> printf("Disk size:\t\t%*s\n", width,
>> df_pretty_sizes(total_disk, mode));
>>
>> it would be translated (note the '%*s'):
>>
>> if (mode == DF_HUMAN_UNIT)
>> printf("Disk size:\t\t%*s%s\n", width-2,
>> df_pretty_sizes_number(total_disk),
>> df_pretty_sizes_unit(total_disk));
>> else
>> printf("Disk size:\t\t%*lld\n", width, total_disk);
>
> So use mode as the argument in the second case, just like you did in the
> first.
>
> printf("Disk dize:\t\t"sz_fmt"\n", sz_arg(total_disk, mode, width));
>
> #define sz_fmt "%*llu%s"
> #define sz_fmt(v,m,w) width(w, m), scaled(v, m), units(v, m)
I suppose s/sz_fmt/sz_arg/
> And again, the reason we jump through these mildly distasteful hoops is
> that *it gets rid of allocated strings entirely*.
I am not entirely convinced, however if you prepare a patch I will
integrate it quickly
> That bug in df_pretty_sizes() where it allocates a 20 byte buffer to
> store a string that can be 21 bytes long with its null? It'd just
> vanish. Not needed.
Good catch
>> To avoid all this mess, we should add another conversion specifier with
>> the function register_printf_function(). Unfortunately I was not able to
>> find the equivalent one for sprintf().
>
> Doesn't that prevent compile-time verification that the types of the
> format specifiers match the arguments?
Yes this was another cons...
>
> - z
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5
next prev parent reply other threads:[~2013-02-25 20:59 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-23 13:46 [PATCH V2][BTRFS-PROGS] Enhance btrfs fi df with raid5/6 support Goffredo Baroncelli
2013-02-23 13:46 ` [PATCH 1/8] Add some helpers to manage the strings allocation/deallocation Goffredo Baroncelli
2013-02-25 2:20 ` Eric Sandeen
2013-02-25 19:59 ` Goffredo Baroncelli
2013-02-25 20:19 ` Zach Brown
2013-02-25 21:00 ` Goffredo Baroncelli [this message]
2013-02-23 13:46 ` [PATCH 2/8] Enhance the command btrfs filesystem df Goffredo Baroncelli
2013-02-23 13:46 ` [PATCH 3/8] Create the man page entry for the command btrfs fi df Goffredo Baroncelli
2013-02-23 13:46 ` [PATCH 4/8] Add helpers functions to handle the printing of data in tabular format Goffredo Baroncelli
2013-02-23 13:46 ` [PATCH 5/8] Add command btrfs filesystem disk-usage Goffredo Baroncelli
2013-02-23 13:46 ` [PATCH 6/8] Create entry in man page for " Goffredo Baroncelli
2013-02-23 13:46 ` [PATCH 7/8] Add btrfs device disk-usage command Goffredo Baroncelli
2013-02-23 13:46 ` [PATCH 8/8] Create a new entry in btrfs man page for btrfs device disk-usage Goffredo Baroncelli
2013-02-25 17:38 ` [PATCH V2][BTRFS-PROGS] Enhance btrfs fi df with raid5/6 support Zach Brown
2013-02-26 11:09 ` Martin Steigerwald
2013-02-26 11:28 ` Gareth Pye
2013-02-26 12:58 ` Martin Steigerwald
2013-02-26 13:15 ` Martin Steigerwald
2013-02-26 12:55 ` Martin Steigerwald
-- strict thread matches above, loose matches on Subject: below --
2013-03-10 12:17 [PATCH V3][BTRFS-PROGS] " Goffredo Baroncelli
2013-03-10 12:17 ` [PATCH 1/8] Add some helpers to manage the strings allocation/deallocation Goffredo Baroncelli
2013-03-10 14:34 ` Wang Shilong
2013-03-10 14:51 ` Goffredo Baroncelli
2013-02-18 21:04 [PATCH][BTRFS-PROGS] Enhance btrfs fi df with raid5/6 support Goffredo Baroncelli
2013-02-18 21:04 ` [PATCH 1/8] Add some helpers to manage the strings allocation/deallocation Goffredo Baroncelli
2013-02-18 23:08 ` Zach Brown
2013-02-19 7:07 ` Goffredo Baroncelli
2013-02-19 17:21 ` Zach Brown
2013-02-19 17:44 ` Goffredo Baroncelli
2013-02-19 17:59 ` Zach Brown
2013-02-19 21:28 ` Goffredo Baroncelli
2013-02-19 21:40 ` Zach Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=512BD0EC.8040707@gmail.com \
--to=kreijack@gmail.com \
--cc=kreijack@inwind.it \
--cc=linux-btrfs@vger.kernel.org \
--cc=sandeen@redhat.com \
--cc=zab@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).