From: Zach Brown <zab@redhat.com>
To: Anand Jain <anand.jain@oracle.com>
Cc: linux-btrfs@vger.kernel.org, dsterba@suse.cz
Subject: Re: [PATCH v2] btrfs-progs: device add should check existing FS before adding
Date: Fri, 27 Sep 2013 11:32:46 -0700 [thread overview]
Message-ID: <20130927183246.GW30372@lenny.home.zabbo.net> (raw)
In-Reply-To: <1380303005-10164-1-git-send-email-anand.jain@oracle.com>
> @@ -49,14 +50,17 @@ static int cmd_add_dev(int argc, char **argv)
> int i, fdmnt, ret=0, e;
> DIR *dirstream = NULL;
> int discard = 1;
> + int force = 0;
> + char estr[100];
>
> + res = test_dev_for_mkfs(argv[i], force, estr);
> + if (res) {
> + fprintf(stderr, "%s", estr);
> continue;
> }
This test_dev_for_mkfs() error string interface is bad. The caller
should not have to magically guess the string size that the function is
going to use. Especially because users can trivial provide giant paths
that exhaust that tiny buffer. If an arbitrarily too small buffer in
the caller was needed at all, its length should have been passed in with
the string pointer. (Or a string struct that all C projects eventually
grow.)
But all the callers just immediately print it anyway. Get rid of that
string argument entirely and just have test_dev_for_mkfs() print the
strings.
- z
next prev parent reply other threads:[~2013-09-27 18:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-27 17:30 [PATCH v2] btrfs-progs: device add should check existing FS before adding Anand Jain
2013-09-27 18:32 ` Zach Brown [this message]
2013-09-28 14:34 ` Anand Jain
-- strict thread matches above, loose matches on Subject: below --
2013-09-27 16:45 [PATCH] btrfs-progs: calculate disk space that a subvol could free Anand Jain
2013-09-29 15:15 ` [PATCH V2] btrfs-progs: device add should check existing FS before adding Anand Jain
2013-09-29 15:26 ` Anand Jain
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=20130927183246.GW30372@lenny.home.zabbo.net \
--to=zab@redhat.com \
--cc=anand.jain@oracle.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
/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).