From patchwork Mon Dec 14 14:00:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 4818 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=79.140.41.39; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dkim=pass reason="1024-bit key; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=puTFLKgV; dkim-adsp=pass; dkim-atps=neutral Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id CA433818E1 for ; Mon, 14 Dec 2015 15:00:34 +0100 (CET) Received: from sven-desktop.home.narfation.org (unknown [IPv6:2a02:3100:2601:d8fd:21dd:bc8d:ce85:3339]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 4FE141C8001; Mon, 14 Dec 2015 15:00:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=narfation.org; s=20121; t=1450101634; bh=4o8d2jY84gKRV6dQ13P1KZMKH1CJIGF5RgL0Akq6vlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=puTFLKgVNFlpkgOo9WxkAFMH2LVQFKLu0tGB8spinPYJZwKP4PsoRRsB2k1qnE3jb mwyRtejsvMQrYDbnsuPMAivu1+uKvaVoJ5cLvqCpGsS4rBN5671Auvjg7AyJyU6rqf BmMElI0dPONjHi4YBKmrJ+MjXdRTzJv1b0OWPt1Y= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 14 Dec 2015 15:00:27 +0100 Message-Id: <1450101627-9692-2-git-send-email-sven@narfation.org> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1450101627-9692-1-git-send-email-sven@narfation.org> References: <1450101627-9692-1-git-send-email-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH 2/2] alfred: Remove bogus length check in debugfs_make_path X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Dec 2015 14:00:35 -0000 The length check never used the mesh_iface length in the size calculation. Instead it used the length of the mountpoint and the format string. But the length of the format string is not the length of the final string. Instead remove this check and depend completely on the return value of snprintf. Signed-off-by: Sven Eckelmann --- debugfs.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/debugfs.c b/debugfs.c index 6404b49..fc39322 100644 --- a/debugfs.c +++ b/debugfs.c @@ -46,19 +46,12 @@ static const char *debugfs_known_mountpoints[] = { int debugfs_make_path(const char *fmt, const char *mesh_iface, char *buffer, int size) { - int len; - if (strlen(debugfs_mountpoint) == 0) { buffer[0] = '\0'; return -1; } - len = strlen(debugfs_mountpoint) + strlen(fmt) + 1; - if (len >= size) - return len+1; - - snprintf(buffer, size-1, fmt, debugfs_mountpoint, mesh_iface); - return 0; + return snprintf(buffer, size, fmt, debugfs_mountpoint, mesh_iface); } static int debugfs_found;