[Reproducible-commits] [dpkg] 07/61: libdpkg: Do not fallback to strlen() when using strcspn()

Jérémy Bobbio lunar at moszumanska.debian.org
Mon Sep 21 09:56:02 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit 93748e328ff3912d3503b323881a2df556d80fad
Author: Guillem Jover <guillem at debian.org>
Date:   Fri Aug 7 03:35:57 2015 +0200

    libdpkg: Do not fallback to strlen() when using strcspn()
    
    The strcspn() function always returns the requested length, there is no
    need to fallback to strlen().
---
 lib/dpkg/pkg-format.c | 4 ----
 lib/dpkg/pkg-show.c   | 9 ++-------
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/lib/dpkg/pkg-format.c b/lib/dpkg/pkg-format.c
index d21c5a7..fbf18be 100644
--- a/lib/dpkg/pkg-format.c
+++ b/lib/dpkg/pkg-format.c
@@ -294,8 +294,6 @@ virt_source_package(struct varbuf *vb,
 		name = pkg->set->name;
 
 	len = strcspn(name, " ");
-	if (len == 0)
-		len = strlen(name);
 
 	varbuf_add_buf(vb, name, len);
 }
@@ -319,8 +317,6 @@ virt_source_version(struct varbuf *vb,
 		version++;
 
 		len = strcspn(version, ")");
-		if (len == 0)
-			len = strlen(version);
 
 		varbuf_add_buf(vb, version, len);
 	}
diff --git a/lib/dpkg/pkg-show.c b/lib/dpkg/pkg-show.c
index 73304d1..93f8f09 100644
--- a/lib/dpkg/pkg-show.c
+++ b/lib/dpkg/pkg-show.c
@@ -131,20 +131,15 @@ pkg_name(struct pkginfo *pkg, enum pkg_name_arch_when pnaw)
 }
 
 const char *
-pkg_summary(const struct pkginfo *pkg, const struct pkgbin *pkgbin, int *len_ret)
+pkg_summary(const struct pkginfo *pkg, const struct pkgbin *pkgbin, int *len)
 {
 	const char *pdesc;
-	size_t len;
 
 	pdesc = pkgbin->description;
 	if (!pdesc)
 		pdesc = _("(no description available)");
 
-	len = strcspn(pdesc, "\n");
-	if (len == 0)
-		len = strlen(pdesc);
-
-	*len_ret = len;
+	*len = strcspn(pdesc, "\n");
 
 	return pdesc;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list