diff --git a/ChangeLog b/ChangeLog index c66c3ed0..96405596 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2004-08-09 Benoît Dejean + + * configure.in: Added -gnu89 to CFLAGS. + + * examples/Makefile.am: Fixed LDFLAGS. + + * sysdeps/common/fsusage.c: (glibtop_get_fsusage_s): + * sysdeps/linux/fsusage.c: (linux_2_6_0): + * sysdeps/linux/proctime.c: (glibtop_get_proc_time_s): + * sysdeps/linux/sysinfo.c: (init_sysinfo): Fixed C89 issues. + + Closes #149375. + 2004-08-03 Benoît Dejean * NEWS: diff --git a/configure.in b/configure.in index 1f841ba1..9f0c0e55 100644 --- a/configure.in +++ b/configure.in @@ -347,6 +347,7 @@ AC_SUBST(machine_incs) if test "$GCC" = "yes" ; then CFLAGS="\ -Wall \ + -std=gnu89 \ -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \ -Wnested-externs -Wpointer-arith \ -Wcast-align -Wsign-compare \ diff --git a/examples/Makefile.am b/examples/Makefile.am index 1b8c85fc..1f774792 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -24,7 +24,7 @@ first_static_LDADD = $(first_LDADD) first_static_LDFLAGS = -static second_SOURCES = second.c -second_LDADD = $(top_builddir)/lib/libgtop-2.0.la +second_LDADD = $(top_builddir)/lib/libgtop-2.0.la -lm second_static_SOURCES = $(second_SOURCES) second_static_LDADD = $(second_LDADD) @@ -71,7 +71,7 @@ mountlist_static_LDFLAGS= -static smp_SOURCES = smp.c -smp_LDADD = $(top_builddir)/lib/libgtop-2.0.la +smp_LDADD = $(top_builddir)/lib/libgtop-2.0.la -lm smp_static_SOURCES = $(smp_SOURCES) smp_static_LDADD = $(smp_LDADD) diff --git a/sysdeps/common/fsusage.c b/sysdeps/common/fsusage.c index 6963581f..579d4ba2 100644 --- a/sysdeps/common/fsusage.c +++ b/sysdeps/common/fsusage.c @@ -134,8 +134,8 @@ void _glibtop_linux_get_fsusage_read_write(glibtop *server, #define _glibtop_get_fsusage_read_write(S, B, P) \ _glibtop_linux_get_fsusage_read_write(S, B, P) - #else /* default fallback */ +#warning glibtop_get_fsusage .read .write are not implemented. #define _glibtop_get_fsusage_read_write(S, B, P) ((void)0) #endif @@ -147,6 +147,20 @@ void glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, const char *path) { +#if defined STAT_STATFS3_OSF1 + struct statfs fsd; +#elif defined STAT_STATFS2_FS_DATA /* Ultrix */ + struct fs_data fsd; +#elif defined STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */ + struct statfs fsd; +#elif defined STAT_STATVFS /* SVR4 */ + struct statvfs fsd; +#elif defined STAT_STATFS2_FSIZE /* 4.4BSD */ + struct statfs fsd; +#elif defined STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */ + struct stafs fsd; +#endif + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_fsusage)); @@ -155,8 +169,6 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, #ifdef STAT_STATFS3_OSF1 - struct statfs fsd; - if (statfs (path, &fsd, sizeof (struct statfs)) != 0) return; @@ -166,8 +178,6 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, #ifdef STAT_STATFS2_FS_DATA /* Ultrix */ - struct fs_data fsd; - if (statfs (path, &fsd) != 1) return; @@ -175,7 +185,7 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, buf->blocks = PROPAGATE_ALL_ONES (fsd.fd_req.btot); buf->bfree = PROPAGATE_ALL_ONES (fsd.fd_req.bfree); buf->bavail = PROPAGATE_TOP_BIT (fsd.fd_req.bfreen); - // buf->bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.fd_req.bfreen) != 0; + /* buf->bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.fd_req.bfreen) != 0; */ buf->files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot); buf->ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree); @@ -183,8 +193,6 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, #ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */ - struct statfs fsd; - if (statfs (path, &fsd) < 0) return; @@ -209,8 +217,6 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, #ifdef STAT_STATFS2_FSIZE /* 4.4BSD */ - struct statfs fsd; - if (statfs (path, &fsd) < 0) return; @@ -224,8 +230,6 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, # define f_bavail f_bfree # endif - struct statfs fsd; - if (statfs (path, &fsd, sizeof fsd, 0) < 0) return; @@ -242,8 +246,6 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, #ifdef STAT_STATVFS /* SVR4 */ - struct statvfs fsd; - if (statvfs (path, &fsd) < 0) return; @@ -260,7 +262,7 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, buf->blocks = PROPAGATE_ALL_ONES (fsd.f_blocks); buf->bfree = PROPAGATE_ALL_ONES (fsd.f_bfree); buf->bavail = PROPAGATE_TOP_BIT (fsd.f_bavail); - // buf->bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.f_bavail) != 0; + /* buf->bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.f_bavail) != 0; */ buf->files = PROPAGATE_ALL_ONES (fsd.f_files); buf->ffree = PROPAGATE_ALL_ONES (fsd.f_ffree); diff --git a/sysdeps/linux/fsusage.c b/sysdeps/linux/fsusage.c index c3a198b3..caf6bace 100644 --- a/sysdeps/linux/fsusage.c +++ b/sysdeps/linux/fsusage.c @@ -30,7 +30,8 @@ static void linux_2_6_0(glibtop *server, glibtop_fsusage *buf, const char *path) { if(strcmp(emnt->mnt_dir, path) != 0) continue; - + else + { char filename[64]; /* magic */ char buffer[1024]; /* magic */ @@ -75,6 +76,7 @@ static void linux_2_6_0(glibtop *server, glibtop_fsusage *buf, const char *path) buf->read = strtoull(p, &p, 0); p = skip_token(p); buf->write = strtoull(p, &p, 0); + } } endmntent(mtab); diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c index d32f9e45..d7e14e94 100644 --- a/sysdeps/linux/proctime.c +++ b/sysdeps/linux/proctime.c @@ -74,9 +74,10 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) p = skip_multiple_token (p, 3); - // timeout is 0 on 2.4 and "thread_number" on 2.6 - // lets skip it (using previous skip_multiple_token) - // buf->timeout = strtoull (p, &p, 0); + /* timeout is 0 on 2.4 and "thread_number" on 2.6 + lets skip it (using previous skip_multiple_token) + buf->timeout = strtoull (p, &p, 0); + */ buf->it_real_value = strtoull (p, &p, 0); /* seconds since epoch */ diff --git a/sysdeps/linux/sysinfo.c b/sysdeps/linux/sysinfo.c index bf67bf6b..29191ac2 100644 --- a/sysdeps/linux/sysinfo.c +++ b/sysdeps/linux/sysinfo.c @@ -37,6 +37,7 @@ static void init_sysinfo (glibtop *server) { char buffer [BUFSIZ]; + gchar ** processors; if(G_LIKELY(sysinfo.flags)) return; @@ -45,8 +46,7 @@ init_sysinfo (glibtop *server) file_to_buffer(server, buffer, FILENAME); /* cpuinfo records are seperated by a blank line */ - gchar ** const processors = g_strsplit(buffer, "\n\n", 0); - + processors = g_strsplit(buffer, "\n\n", 0); for(sysinfo.ncpu = 0; sysinfo.ncpu < GLIBTOP_NCPU && processors[sysinfo.ncpu] && *processors[sysinfo.ncpu];