summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-04-22 10:57:59 +0000
committerLennart Poettering <lennart@poettering.net>2006-04-22 10:57:59 +0000
commit48850f18f65f536446a01315245da99dfb94f8f8 (patch)
treea7b4111c7ad93774ff7b51eaabc0462b5aa0001f
parentfc02fb4cf63f58110a19285bd097bdce744a3ecc (diff)
compile with fascist gcc warnings and fix all issues found
git-svn-id: file:///home/lennart/svn/public/syrep/trunk@103 07ea20a6-d2c5-0310-9e02-9ef735347d72
-rw-r--r--configure.ac29
-rw-r--r--src/cleanup.c1
-rw-r--r--src/context.c4
-rw-r--r--src/dbutil.c2
-rw-r--r--src/diff.c3
-rw-r--r--src/list.c1
-rw-r--r--src/md5util.c10
-rw-r--r--src/merge.c1
-rw-r--r--src/package.c5
-rw-r--r--src/package.h4
-rw-r--r--src/util.c6
11 files changed, 42 insertions, 24 deletions
diff --git a/configure.ac b/configure.ac
index 7b6f91a..936b22d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,13 +32,32 @@ AC_GNU_SOURCE
AC_SUBST(PACKAGE_URL, [http://0pointer.de/lennart/projects/syrep/])
-# If using GCC specifiy some additional parameters
+# GCC flags
+
+test_gcc_flag() {
+ AC_LANG_CONFTEST([int main() {}])
+ $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
+ ret=$?
+ rm -f conftest.o
+ return $ret
+}
+
+# If using GCC specify some additional parameters
if test "x$GCC" = "xyes" ; then
- CFLAGS="$CFLAGS -pipe -W -Wall -pedantic"
- AC_LANG_CONFTEST([int main() {}])
- $CC -c conftest.c -std=c99 -Wno-unused-parameter $CFLAGS > /dev/null 2> /dev/null && CFLAGS="$CFLAGS -std=c99 -Wno-unused-parameter"
- rm -f conftest.o
+ # We use gnu99 instead of c99 because many have interpreted the standard
+ # in a way that int64_t isn't defined on non-64 bit platforms.
+ DESIRED_FLAGS="-std=gnu99 -Wall -W -Wextra -pedantic -pipe -Wformat -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter"
+
+ for flag in $DESIRED_FLAGS ; do
+ AC_MSG_CHECKING([whether $CC accepts $flag])
+ if test_gcc_flag $flag ; then
+ CFLAGS="$CFLAGS $flag"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ done
fi
if type -p stow > /dev/null && test -d /usr/local/stow ; then
diff --git a/src/cleanup.c b/src/cleanup.c
index f362240..6d1b009 100644
--- a/src/cleanup.c
+++ b/src/cleanup.c
@@ -29,6 +29,7 @@
#include "syrep.h"
#include "util.h"
+#include "cleanup.h"
int cleanup(const char *root) {
char p[PATH_MAX];
diff --git a/src/context.c b/src/context.c
index 84dd4b1..c7289df 100644
--- a/src/context.c
+++ b/src/context.c
@@ -75,7 +75,7 @@ int db_context_free(struct syrep_db_context* c) {
}
-static DB* open_db(const char*path, int dup, int recno) {
+static DB* open_db(const char*path, int dupsort, int recno) {
int ret;
DB* db;
@@ -84,7 +84,7 @@ static DB* open_db(const char*path, int dup, int recno) {
return NULL;
}
- if (dup && !recno)
+ if (dupsort && !recno)
db->set_flags(db, DB_DUPSORT);
//db->set_pagesize(db, 4096*8);
diff --git a/src/dbutil.c b/src/dbutil.c
index fee6ab1..324e444 100644
--- a/src/dbutil.c
+++ b/src/dbutil.c
@@ -240,7 +240,7 @@ static uint32_t csum_name(const struct syrep_name *name) {
assert(name);
a = adler32(0, NULL, 0);
- a = adler32(a, (uint8_t*) name->path, strlen(name->path));
+ a = adler32(a, (const uint8_t*) name->path, strlen(name->path));
/*fprintf(stderr, "csum: %s -> %u\n", name->path, a);*/
diff --git a/src/diff.c b/src/diff.c
index 7f97ba7..ccb4287 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -308,7 +308,8 @@ static int list_cb(DB *ddb, struct syrep_name *name, struct diff_entry *de, void
switch (de->action) {
case DIFF_COPY: {
char d[33];
- char sizet[100] = " ", *psizet = "";
+ char sizet[100] = " ";
+ const char *psizet = "";
char dst;
const char *root = NULL;
int mf;
diff --git a/src/list.c b/src/list.c
index 1018f8a..bd5523b 100644
--- a/src/list.c
+++ b/src/list.c
@@ -180,7 +180,6 @@ int list(struct syrep_db_context *c) {
if (!m_sort_array) {
DB_BTREE_STAT *statp;
- int ret;
if ((ret = c->db_id_meta->stat(c->db_id_meta, NULL, &statp, 0)) != 0)
break;
diff --git a/src/md5util.c b/src/md5util.c
index 209f0bb..d5cc45d 100644
--- a/src/md5util.c
+++ b/src/md5util.c
@@ -98,19 +98,19 @@ int fdmd5(int fd, off_t l, uint8_t md[]) {
}
while (l) {
- ssize_t r;
+ ssize_t k;
- if ((r = read(fd, p, BUFSIZE)) < 0) {
+ if ((k = read(fd, p, BUFSIZE)) < 0) {
fprintf(stderr, "read(): %s\n", strerror(errno));
goto finish;
}
- if (!r)
+ if (!k)
break;
- md5_append(&s, p, r);
+ md5_append(&s, p, k);
- l -= r;
+ l -= k;
}
}
diff --git a/src/merge.c b/src/merge.c
index 7cca266..0aad797 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -37,6 +37,7 @@
#include "dbutil.h"
#include "package.h"
#include "util.h"
+#include "merge.h"
struct cb_info {
struct syrep_db_context *c1; /* remote */
diff --git a/src/package.c b/src/package.c
index 89d16cb..8ae6508 100644
--- a/src/package.c
+++ b/src/package.c
@@ -40,9 +40,6 @@
#include "util.h"
#include "syrep.h"
-/* Import mkdtemp */
-char *mkdtemp(char *template);
-
struct package_item;
struct package_item {
@@ -269,7 +266,7 @@ finish:
}
static char *tmp(char *fn, int l) {
- char *t;
+ const char *t;
if (!(t = getenv("TMPDIR")))
if (!(t = getenv("TEMP")))
diff --git a/src/package.h b/src/package.h
index 42486ad..cdb0222 100644
--- a/src/package.h
+++ b/src/package.h
@@ -23,8 +23,8 @@
#include <inttypes.h>
-#define PACKAGE_FILEID (*((uint32_t*) "SREP"))
-#define PACKAGE_FILEIDCOMPRESSED (*((uint32_t*) "CREP"))
+#define PACKAGE_FILEID (*((const uint32_t*) "SREP"))
+#define PACKAGE_FILEIDCOMPRESSED (*((const uint32_t*) "CREP"))
#define PACKAGE_ITEMNAMELEN 32
diff --git a/src/util.c b/src/util.c
index 964e36f..96b99c1 100644
--- a/src/util.c
+++ b/src/util.c
@@ -296,7 +296,7 @@ int copy_fd(int sfd, int dfd, off_t l) {
while (l > 0) {
off_t n;
- size_t m = MIN(l, BUFSIZE);
+ m = MIN(l, BUFSIZE);
if ((n = loop_read(sfd, buf, m)) != m) {
@@ -761,13 +761,13 @@ ssize_t loop_write(int fd, const void *d, size_t l) {
ssize_t r;
if ((r = write(fd, p, l)) <= 0)
- return p-(uint8_t*)d > 0 ? p-(uint8_t*) d : r;
+ return p-(const uint8_t*)d > 0 ? p-(const uint8_t*) d : r;
p += r;
l -= r;
}
- return p-(uint8_t*) d;
+ return p-(const uint8_t*) d;
}
char *snprint_off(char *s, size_t l, off_t off) {