]> pd.if.org Git - zpackage/commitdiff
add warnings to compile flags and fix
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 4 Mar 2017 17:34:19 +0000 (11:34 -0600)
committerNathan Wagner <nw@hydaspes.if.org>
Sun, 5 Mar 2017 15:05:15 +0000 (09:05 -0600)
Makefile
elf/soname.c
lib/db.c
lib/zpm.c

index 4685b57485687b39690ab03773bd5194a023786c..ffb3f5baad52ac382af52c8aee53b89e30b5c887 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CFLAGS=-Wall -std=c99 -Ilib -Ielf -I. -Ilzma/api
+CFLAGS=-Wall -W -Wextra -Werror -std=c99 -Ilib -Ielf -I. -Ilzma/api
 
 LZMAFLAGS=-Ilzma/api -Ilzma/tuklib -Ilzma/lzma -Ilzma/common -Ilzma/check -Ilzma/lz -Ilzma/rangecoder -Ilzma/simple -Ilzma/delta -DHAVE_CHECK_CRC64 -DHAVE_CHECK_CRC32 -DHAVE_ENCODER_LZMA2 -DHAVE_DECODER_LZMA2 -DHAVE_MF_BT4
 
@@ -60,7 +60,7 @@ newdb.c: db.sql
        echo ", 0};" >> $@
 
 lib/sqlite3.o: lib/sqlite3.c lib/config.h
-       $(CC) $(CFLAGS) -D_HAVE_SQLITE_CONFIG_H=1 -c -o $@ $<
+       $(CC) -Wall -std=c99 -Ilib -D_HAVE_SQLITE_CONFIG_H=1 -c -o $@ $<
 
 $(LZMAOBJ):
        $(CC) $(CFLAGS) $(LZMAFLAGS) -c -o $@ $*.c
index 8b6c451275f8a8e42d8f50cb58b028d380a7cc07..06e56624eaccffbf30a8d928e09678127def7c13 100644 (file)
@@ -23,6 +23,11 @@ int main(int ac, char **av) {
        char *name, *dynname;
        Elf64_Dyn *dent;
 
+       if (ac < 2) {
+               fprintf(stderr, "usage: soname <file>\n");
+               exit(EXIT_FAILURE);
+       }
+
        if (lstat(av[1], &sbuf) == -1) {
                exit(1);
        }
@@ -42,7 +47,7 @@ int main(int ac, char **av) {
                exit(1);
        }
        /* not at least the size of the elf header? */
-       if (sbuf.st_size < sizeof(Elf64_Ehdr)) {
+       if ((size_t)sbuf.st_size < sizeof(Elf64_Ehdr)) {
                exit(1);
        }
 
index 98608b3e26fa659d06685997f95d5842c68a9172..9b19b74913d1f055b14c7566ab9b8c0661465c02 100644 (file)
--- a/lib/db.c
+++ b/lib/db.c
@@ -16,6 +16,7 @@
 
 static int callback(void *NotUsed, int argc, char **argv, char **azColName){
        int i;
+       NotUsed = 0; /* suppress warning */
        for(i=0; i<argc; i++){
                printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
        }
index 99984fbef7d645864fa235fdfdd072dd1a9a0682..d9041ff33c6daf3b4510022fd6e7b2387ae983d9 100644 (file)
--- a/lib/zpm.c
+++ b/lib/zpm.c
@@ -372,7 +372,7 @@ int zpm_readopts(struct zpm *pkg, int ac, char **av) {
 
        /* now, parse the options, return optind so the caller can adjust if needed */
 
-       return 1;
+       return av ? ac : 1;
 }
 
 int zpm_extract(struct zpm *pkg, char *hash, char *path, int mode) {
@@ -450,6 +450,7 @@ int zpm_extract(struct zpm *pkg, char *hash, char *path, int mode) {
        //fprintf(stderr, "uncompressing %d bytes at %p, expect %lld\n", blobsize, xzdata, (long long int)size);
        uncompresslzma(xzdata, blobsize, out);
        fclose(out);
+       chmod(path, mode);
 
        sqlite3_finalize(ifile);
 
@@ -498,7 +499,7 @@ int zpm_hash(char *path, char *hash, uint32_t flags) {
        }
        hash[64] = 0;
        munmap(content, sbuf.st_size);
-       return 1;
+       return flags ? fd : 1;
 }
 
 static sqlite3_stmt *run_for_hash(sqlite3 *db, char *sql, char *hash) {
@@ -712,6 +713,7 @@ int zpm_import(struct zpm *pkg, char *path, uint32_t flags, char *hash) {
                hash = hashbuf;
        }
 
+       flags = 0; /* suppress warning, probably use to follow symlinks */
        /* mmap the file */
        fd = open(path, O_RDONLY);
        if (fd == -1) {