linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: send: replace check with an assert in gen_unique_name
@ 2014-02-03 17:24 David Sterba
  0 siblings, 0 replies; only message in thread
From: David Sterba @ 2014-02-03 17:24 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The buffer passed to snprintf can hold the fully expanded format string,
64 = 3x largest ULL + 3x char + trailing null.  I don't think that removing the
check entirely is a good idea, hence the ASSERT.

Signed-off-by: David Sterba <dsterba@suse.cz>
---


 fs/btrfs/send.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 730dce395858..f65355dfc882 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -1408,11 +1408,7 @@ static int gen_unique_name(struct send_ctx *sctx,
 	while (1) {
 		len = snprintf(tmp, sizeof(tmp), "o%llu-%llu-%llu",
 				ino, gen, idx);
-		if (len >= sizeof(tmp)) {
-			/* should really not happen */
-			ret = -EOVERFLOW;
-			goto out;
-		}
+		ASSERT(len < sizeof(tmp));
 
 		di = btrfs_lookup_dir_item(NULL, sctx->send_root,
 				path, BTRFS_FIRST_FREE_OBJECTID,
-- 
1.7.9


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-02-03 17:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-03 17:24 [PATCH] btrfs: send: replace check with an assert in gen_unique_name David Sterba

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).