Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=75c1c5a2c0763bba3632af03ef950808ac9b97f0

commit 75c1c5a2c0763bba3632af03ef950808ac9b97f0
Author: Michel Hermier <[email protected]>
Date:   Fri May 10 08:06:37 2013 +0200

libflib: Add f_strlen, which return 0 if NULL is passed.

diff --git a/lib/libflib/fstring.c b/lib/libflib/fstring.c
index 34540b8..be76bf9 100644
--- a/lib/libflib/fstring.c
+++ b/lib/libflib/fstring.c
@@ -25,8 +25,12 @@

#include "fstring.h"

-char *f_strdup (const char *str) {
-       return str != NULL ? strdup (str) : NULL;
+char *f_strdup (const char *s) {
+       return s != NULL ? strdup (s) : NULL;
+}
+
+size_t f_strlen (const char *s) {
+       return s != NULL ? strlen (s) : NULL;
}

/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libflib/fstring.h b/lib/libflib/fstring.h
index 167fe49..5a4fc5a 100644
--- a/lib/libflib/fstring.h
+++ b/lib/libflib/fstring.h
@@ -23,7 +23,9 @@

#include "string.h"

-char *f_strdup (const char *str);
+char *f_strdup (const char *s);
+
+size_t f_strlen (const char *s);

#endif /* F_STRING_H */

diff --git a/lib/libpacman/package.c b/lib/libpacman/package.c
index 0c0f4ec..da54eca 100644
--- a/lib/libpacman/package.c
+++ b/lib/libpacman/package.c
@@ -272,7 +272,7 @@ pmpkg_t *_pacman_pkg_load(const char *pkgfile)
struct utsname name;
pmpkg_t *info = NULL;

-       if(pkgfile == NULL || strlen(pkgfile) == 0) {
+       if(f_strlen(pkgfile) == 0) {
RET_ERR(PM_ERR_WRONG_ARGS, NULL);
}

@@ -313,7 +313,7 @@ pmpkg_t *_pacman_pkg_load(const char *pkgfile)
close(fd);
goto error;
}
-                       if(!strlen(info->name)) {
+                       if(f_strlen(info->name) == 0) {
_pacman_log(PM_LOG_ERROR, _("missing package name in %s"), pkgfile);
pm_errno = PM_ERR_PKG_INVALID;
unlink(descfile);
@@ -321,7 +321,7 @@ pmpkg_t *_pacman_pkg_load(const char *pkgfile)
close(fd);
goto error;
}
-                       if(!strlen(info->version)) {
+                       if(f_strlen(info->version) == 0) {
_pacman_log(PM_LOG_ERROR, _("missing package version in %s"), pkgfile);
pm_errno = PM_ERR_PKG_INVALID;
unlink(descfile);
@@ -330,7 +330,7 @@ pmpkg_t *_pacman_pkg_load(const char *pkgfile)
goto error;
}
if(handle->trans && !(handle->trans->flags & PM_TRANS_FLAG_NOARCH)) {
-                               if(!strlen(info->arch)) {
+                               if(f_strlen(info->arch) == 0) {
_pacman_log(PM_LOG_ERROR, _("missing package architecture in %s"), pkgfile);
pm_errno = PM_ERR_PKG_INVALID;
unlink(descfile);
@@ -340,7 +340,7 @@ pmpkg_t *_pacman_pkg_load(const char *pkgfile)
}

uname (&name);
-                               if(strncmp(name.machine, info->arch, 
strlen(info->arch))) {
+                               if(strncmp(name.machine, info->arch, 
f_strlen(info->arch))) {
_pacman_log(PM_LOG_ERROR, _("wrong package architecture in %s"), pkgfile);
pm_errno = PM_ERR_WRONG_ARCH;
unlink(descfile);
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to