linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Zach Brown <zab@redhat.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: Sat, 28 Sep 2013 22:34:00 +0800	[thread overview]
Message-ID: <5246E8D8.10205@oracle.com> (raw)
In-Reply-To: <20130927183246.GW30372@lenny.home.zabbo.net>

On 09/28/2013 02:32 AM, Zach Brown wrote:
>> @@ -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.

  Right. But this patch didn't introduce test_dev_for_mkfs()
  revamp of it will be good in a separate patch as it touches
  other functions as well.

Thanks, Anand



  reply	other threads:[~2013-09-28 14:34 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
2013-09-28 14:34   ` Anand Jain [this message]
  -- 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=5246E8D8.10205@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --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).