Hello,
The code in several places uses "illegal" C constructs. For example, in aide.h
is this: #if AIDE_OFF_TYPE == off64_t. The #if can only compare integers. So,
what I did was look at how this was really being used. If all cases it was to
decide whether to use "long long" or "long".
The solution was to add checks for the sizeof of off64_t and long long. If
off64_t is not available, the size will be 0. Long long should be always defined
and 8. So, we should be able to use this comparison to cleanup the "off64_t" is
not defined warnings. Looking at the other warnings, they are also related to
size issues in format strings. The following patch cleans all this up.
-Steve
diff -urp aide.orig/configure.in aide/configure.in
--- aide.orig/configure.in 2010-02-24 14:55:18.000000000 -0500
+++ aide/configure.in 2010-02-24 15:48:39.000000000 -0500
@@ -251,6 +251,7 @@ AC_CHECK_TYPES([byte, ushort, ulong, u16
AC_CHECK_SIZEOF(unsigned short, 2)
AC_CHECK_SIZEOF(unsigned int, 4)
AC_CHECK_SIZEOF(unsigned long, 4)
+AC_CHECK_SIZEOF(long long, 8)
AC_CHECK_SIZEOF(unsigned long long, 8)
AC_C_LONG_DOUBLE
@@ -572,6 +573,8 @@ AC_CHECK_FUNC(lstat64,
saved_CFLAGS="$CFLAGS"
CFLAGS+=" $AIDE_DEFS"
+AC_CHECK_SIZEOF(off_t)
+AC_CHECK_SIZEOF(off64_t)
AC_CACHE_CHECK([for LFS ino_t],AIDE_INO_TYPE,[
AC_TRY_RUN([
#include <unistd.h>
diff -urp aide.orig/include/aide.h aide/include/aide.h
--- aide.orig/include/aide.h 2010-02-24 14:55:18.000000000 -0500
+++ aide/include/aide.h 2010-02-24 15:40:03.000000000 -0500
@@ -67,7 +67,7 @@ int snprintf(char *str,size_t count,cons
# define HAVE_STRTOIMAX
#endif
-#if AIDE_OFF_TYPE == off64_t
+#if SIZEOF_OFF64_T == SIZEOF_LONG_LONG
# ifdef HAVE_STRTOLL
# define AIDE_STRTOLL_FUNC strtoll
# else
diff -urp aide.orig/src/commandconf.c aide/src/commandconf.c
--- aide.orig/src/commandconf.c 2010-02-24 14:55:18.000000000 -0500
+++ aide/src/commandconf.c 2010-02-24 15:41:21.000000000 -0500
@@ -314,9 +314,9 @@ int db_input_wrapper(char* buf, int max_
buf[0]='\0';
} else {
/* gzread returns 0 even if uncompressed bytes were read*/
- error(240,"nread=%d,strlen(buf)=%u,errno=%s,gzerr=%s\n",
- retval,strnlen((char*)buf, max_size),strerror(errno),
- gzerror(*db_gzp,&err));
+ error(240,"nread=%d,strlen(buf)=%lu,errno=%s,gzerr=%s\n",
+ retval,(unsigned long)strnlen((char*)buf, max_size),
+ strerror(errno),gzerror(*db_gzp,&err));
if(retval==0){
retval=strnlen((char*)buf, max_size);
}
diff -urp aide.orig/src/compare_db.c aide/src/compare_db.c
--- aide.orig/src/compare_db.c 2010-02-24 14:55:18.000000000 -0500
+++ aide/src/compare_db.c 2010-02-24 15:42:10.000000000 -0500
@@ -462,7 +462,7 @@ void print_single_xattrs(xattrs_type* xa
size_t num = 0;
int width = 0;
- error(2,"num=%u\n", xattrs->num);
+ error(2,"num=%lu\n", (unsigned long)xattrs->num);
width = log10(xattrs->num); /* make them the same width */
@@ -595,7 +595,7 @@ void print_int_changes(const char* name,
}
void print_long_changes(const char* name, AIDE_OFF_TYPE old, AIDE_OFF_TYPE new, int justnew)
{
-#if AIDE_OFF_TYPE == off64_t
+#if SIZEOF_OFF64_T == SIZEOF_LONG_LONG
if (!justnew) {
snprintf(oline,part_len,"%llu",(long long unsigned)old);
}
diff -urp aide.orig/src/db_file.c aide/src/db_file.c
--- aide.orig/src/db_file.c 2010-02-24 14:55:18.000000000 -0500
+++ aide/src/db_file.c 2010-02-24 15:47:06.000000000 -0500
@@ -88,8 +88,8 @@ void handle_gzipped_input(int out,gzFile
exit(1);
}
- error(240,"nread=%d,strlen(buf)=%u,errno=%s,gzerr=%s\n",
- nread,strlen((char*)buf),strerror(errno),
+ error(240,"nread=%d,strlen(buf)=%lu,errno=%s,gzerr=%s\n",
+ nread,(unsigned long)strlen((char*)buf),strerror(errno),
gzerror(*gzp,&err));
buf[0]='\0';
}
@@ -673,8 +673,8 @@ int db_writelong(AIDE_OFF_TYPE i,FILE* f
dofprintf(" ");
}
-#if AIDE_OFF_TYPE == off64_t
- return dofprintf("%lli",i);
+#if SIZEOF_OFF64_T == SIZEOF_LONG_LONG
+ return dofprintf("%lli",(long long)i);
#else
return dofprintf("%li",i);
#endif
|