Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/util/vercmp.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-10-11 20:20:06 -0500
committerDan McGee <dan@archlinux.org>2010-10-11 20:29:22 -0500
commit0ff2a9149711b9179d288f579c792890cd81d79b (patch)
treee6828df064a844ecf44992f8773f3a4c69369d73 /src/util/vercmp.c
parent05f0a28932c1acab7a9ddb58435d69626dad54da (diff)
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 <dan@archlinux.org>
Diffstat (limited to 'src/util/vercmp.c')
-rw-r--r--src/util/vercmp.c23
1 files changed, 7 insertions, 16 deletions
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 <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#include <stdio.h> /* printf */
#include <string.h> /* 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 <ver1> <ver2>\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);