From 0ff2a9149711b9179d288f579c792890cd81d79b Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 11 Oct 2010 20:20:06 -0500 Subject: util: fall cleaning on single file programs * Add a bunch of static declarations where possible * Fix void functions to be proper syntax, e.g. void func(void) * Consistency fixes (such as argv references) * Remove dead str_cmp() function from testdb * Remove unneeded config.h header includes * vercmp: remove completely unnecessary string copying Signed-off-by: Dan McGee --- src/util/vercmp.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/util/vercmp.c') diff --git a/src/util/vercmp.c b/src/util/vercmp.c index 959dc137..8a785bb8 100644 --- a/src/util/vercmp.c +++ b/src/util/vercmp.c @@ -18,20 +18,16 @@ * along with this program. If not, see . */ -#include "config.h" - #include /* printf */ #include /* strncpy */ #define BASENAME "vercmp" -#define MAX_LEN 255 - /* forward declaration, comes from vercmp.o in libalpm source that is linked in * directly so we don't have any library deps */ int alpm_pkg_vercmp(const char *a, const char *b); -static void usage() +static void usage(void) { fprintf(stderr, "usage: %s \n\n", BASENAME); fprintf(stderr, "return values:\n"); @@ -42,8 +38,8 @@ static void usage() int main(int argc, char *argv[]) { - char s1[MAX_LEN] = ""; - char s2[MAX_LEN] = ""; + const char *s1 = ""; + const char *s2 = ""; int ret; if(argc == 1) { @@ -56,16 +52,11 @@ int main(int argc, char *argv[]) usage(); return(0); } - if(argc > 1) { - strncpy(s1, argv[1], MAX_LEN); - s1[MAX_LEN -1] = '\0'; - } if(argc > 2) { - strncpy(s2, argv[2], MAX_LEN); - s2[MAX_LEN -1] = '\0'; - } else { - printf("0\n"); - return(0); + s2 = argv[2]; + } + if(argc > 1) { + s1 = argv[1]; } ret = alpm_pkg_vercmp(s1, s2); -- cgit v1.2.3-54-g00ecf