dbench: fix compile warnings and update a bit
cover dbench: fix compile warnings and update a bit
Some form of OCD kicked and so this fixes all compile errors on dbench. It also fixes compiling with smbclient as detection of the library wasn't working anymore. This also modernizes the default build output to be a bit more quiet and only if you issue V=1 do you get the details behind what is being built. In case this never ends up on samba's git tree I've put mine up on github [0].
Well, hopefully Debian starts carrying dbench again soon.
[0] https://github.com/mcgrof/dbench
Luis Chamberlain (25):
dbench: simplify open_loadfile() as check_loadfile_ok()
child: fix usage of gzFile and gzopen()
dbench: remove unused double t value
child: fix data type comparison on child_run Makefile.in: disable unused warning for rpc generated code configure.ac: run autoupdate
dbench: update use of time.h or sys/time.h
config.h.in: run autoconf
snprintf: specify safe fallthrough on switches
nfsio.c: include dbench.h before nfs.h
nfsio: remove unused status variable
child: be expicit about string truncation goal
child: do not overlap on memcpy()
dbench.h: use bits/types.h instead of defining uint32 sockio.c: use uint32_t
libnfs.c: fix a few simple compile warnings
libnfs: fix compilation warning for inet_tons
libnfs.c: fix sign conflict compile warning
Makefile.in:
linux_scsi.c: fix redeclaration of _GNU_SOURCE Makefile.in: modernize build output with V=1 or V=0 Makefile.in: declare datarootdir
configure.ac: fix smbclient detection
libiscsi: fix compile warning on data types
smb: fix compilation and disable warning on deprecated-declarations
Makefile.in | 131 +++++++++++++++++++++++++++++++-------------------- child.c | 16 +++++-- config.h.in | 19 -------- configure.ac | 41 +++++++--------- dbench.c | 27 ++++++----- dbench.h | 16 ++++++- libiscsi.c | 2 +- libnfs.c | 15 +++--- linux_scsi.c | 4 -- nfsio.c | 3 +- snprintf.c | 3 ++ sockio.c | 2 +- 12 files changed, 153 insertions(+), 126 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/25 dbench: simplify open_loadfile() as check_loadfile_ok()
open_loadfile() just checks to see if the file.gz exists and is present. Note that if the file is not in the gzip format, gzopen and gzread will not produce an error but just read it without doing any uncompressing. So just rename it to check_loadfile_ok().
While at it fix the incorrect use of gzFile as a pointer. Using it as a pointer works just because the file descriptor can cast to the pointer, but this generates compilation warnings. Fix that as well.
And lastly, just use gzclose(f) for correctness;
--- dbench.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
dbench.c +14 -9
@@ -25,6 +25,7 @@#include "dbench.h" #include "popt.h" #include <sys/sem.h> +#include <stdbool.h> #include <zlib.h> struct options options = {
@@ -60,18 +61,25 @@ static double throughput;struct nb_operations *nb_ops;int global_random; -static gzFile *open_loadfile (void ) +/* +* Note that if the file is not in the gzip format, gzopen and gzread will not +* produce an error but just read it without doing any uncompressing. +*/ +static bool check_loadfile_ok (void ) { -gzFile *f; +gzFile f; -if ((f =gzopen (options.loadfile,"rt" )) !=NULL ) -return f; + f =gzopen (options.loadfile,"rt" ); +if (f) { +gzclose (f); +return true; + }fprintf (stderr,"dbench: error opening '%s': %s\n" , options.loadfile,strerror (errno)); -return NULL ; +return false; }
@@ -253,14 +261,11 @@ static void create_procs(int nprocs, void (*fn)(struct child_struct *, const chaint i, status;int synccount;struct timeval tv; -gzFile *load;struct sembuf sbuf;double t; - load =open_loadfile (); -if (load ==NULL ) { +if (!check_loadfile_ok ())exit (1 ); - }if (nprocs <1 ) { fprintf(stderr,
Signature · 1 line
2.34.1
PATCH 2/25 child: fix usage of gzFile and gzopen()
In reply to Luis ChamberlainThe code uses gzFile as a pointer, but it is not the intended design. This works as a pointer works just as well as the stupid file descriptor. Fix this usage to shut up gcc compilation warnings and make proper use of the API.
--- child.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
child.c +2 -2
@@ -329,7 +329,7 @@ void child_run(struct child_struct *child0, const char *loadfile)char **sparams, **params;char *p;const char *status; -gzFile *gzf; +gzFile gzf;pid_t parent =getppid ();double targett;struct child_struct *child;
@@ -348,7 +348,7 @@ void child_run(struct child_struct *child0, const char *loadfile) } gzf =gzopen (loadfile,"r" ); -if (gzf ==NULL ) { +if (!gzf) {perror (loadfile);exit (1 ); }
Signature · 1 line
2.34.1
PATCH 3/25 dbench: remove unused double t value
In reply to Luis ChamberlainThe value is not used. Nuke it.
--- dbench.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
dbench.c +1 -3
@@ -496,7 +496,7 @@ static void process_opts(int argc, const char **argv)int main (int argc,const char *argv[]) {double total_bytes =0 ; -double t, latency=0 ; +double latency=0 ;int i;setlinebuf (stdout);
@@ -568,8 +568,6 @@ static void process_opts(int argc, const char **argv) latency =MAX (latency, children[i].worst_latency); } - t =timeval_elapsed2 (&tv_start, &tv_end); -if (options.machine_readable) { printf(";%g;%d;%d;%.03f;\n", throughput,
Signature · 1 line
2.34.1
PATCH 4/25 child: fix data type comparison on child_run
In reply to Luis ChamberlainUse an unsigned int when comparing values returned by strlen(). This fixes this compile warning:
child.c:447:39: warning: comparison of integer expressions of different
signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
447 | if (len > strlen(line +13)) {
|--- child.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
child.c +1 -1
@@ -441,7 +441,7 @@ loop_again:int count =RWBUFSIZE ;while (count >0 ) { -int len; +unsigned int len; len = count;if (len >strlen (line +13 )) {
Signature · 1 line
2.34.1
PATCH 5/25 Makefile.in: disable unused warning for rpc generated code
In reply to Luis Chamberlainrpcgen cretes C code with unused variables, so just disable gcc unused variable warning for rpc generated code.
--- Makefile.in | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
Makefile.in +5 -4
@@ -16,6 +16,7 @@ DESTDIR=/ CC=@CC@ CFLAGS=@CFLAGS@ -I. -DVERSION=\"$(VERSION)\" -DDATADIR=\"$(datadir)\" CFLAGS+=`pkg-config --cflags libtirpc` +CFLAGS_RPCGEN=-Wno-unused-variable LIBS+=`pkg-config --libs libtirpc` EXEEXT=@EXEEXT@
@@ -58,7 +59,7 @@ nfs.h: nfs.x mount_xdr.o: mount_xdr.c mount.h @echo Compiling $@ - gcc -g $(CFLAGS) -c mount_xdr.c -o $@ + gcc -g $(CFLAGS) $(CFLAGS_RPCGEN) -c mount_xdr.c -o $@ mount_xdr.c: mount.x @echo Generating $@
@@ -66,7 +67,7 @@ mount_xdr.c: mount.x mount_client.o: mount_client.c mount.h @echo Compiling $@ - gcc -g $(CFLAGS) -c mount_client.c -o $@ + gcc -g $(CFLAGS) $(CFLAGS_RPCGEN) -c mount_client.c -o $@ mount_client.c: mount.x @echo Generating $@
@@ -74,7 +75,7 @@ mount_client.c: mount.x nfs_xdr.o: nfs_xdr.c nfs.h @echo Compiling $@ - gcc $(CFLAGS) -g -c nfs_xdr.c -o $@ + gcc $(CFLAGS) $(CFLAGS_RPCGEN) -g -c nfs_xdr.c -o $@ nfs_xdr.c: nfs.x @echo Generating $@
@@ -82,7 +83,7 @@ nfs_xdr.c: nfs.x nfs_client.o: nfs_client.c nfs.h @echo Compiling $@ - gcc -g $(CFLAGS) -c nfs_client.c -o $@ + gcc -g $(CFLAGS) $(CFLAGS_RPCGEN) -c nfs_client.c -o $@ nfs_client.c: nfs.x @echo Generating $@
Signature · 1 line
2.34.1
PATCH 6/25 configure.ac: run autoupdate
In reply to Luis ChamberlainThere are a few deprecate things, run autoupdate to correct these things.
--- configure.ac | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-)
configure.ac +29 -22
@@ -1,11 +1,11 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT() -AC_PREREQ(2.52) +AC_INIT +AC_PREREQ([2.71]) AC_MSG_NOTICE([Configuring dbench]) -AC_CONFIG_HEADER(config.h) +AC_CONFIG_HEADERS([config.h]) dnl Checks for programs. AC_PROG_CC
@@ -24,7 +24,20 @@ else fi AC_HEADER_DIRENT -AC_HEADER_TIME +m4_warn([obsolete], +[Update your code to rely only on HAVE_SYS_TIME_H, +then remove this warning and the obsolete code below it. +All current systems provide time.h; it need not be checked for. +Not all systems provide sys/time.h, but those that do, all allow +you to include it and time.h simultaneously.])dnl +AC_CHECK_HEADERS_ONCE([sys/time.h]) +# Obsolete code to be removed. +if test $ac_cv_header_sys_time_h = yes; then + AC_DEFINE([TIME_WITH_SYS_TIME],[1],[Define to 1 if you can safely include both <sys/time.h> + and <time.h>. This macro is obsolete.]) +fi +# End of obsolete code. + AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h sys/vfs.h sys/statvfs.h stdint.h)
@@ -58,18 +71,16 @@ if test x"$ac_cv_func_fgetxattr" = x"yes" -o \ fi AC_CACHE_CHECK([for va_copy],dbench_cv_HAVE_VA_COPY,[ -AC_TRY_LINK([#include <stdarg.h> -va_list ap1,ap2;], [va_copy(ap1,ap2);], -dbench_cv_HAVE_VA_COPY=yes,dbench_cv_HAVE_VA_COPY=no)]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h> +va_list ap1,ap2;]], [[va_copy(ap1,ap2);]])],[dbench_cv_HAVE_VA_COPY=yes],[dbench_cv_HAVE_VA_COPY=no])]) if test x"$dbench_cv_HAVE_VA_COPY" = x"yes"; then AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) fi if test x"$dbench_cv_HAVE_VA_COPY" != x"yes"; then AC_CACHE_CHECK([for __va_copy],dbench_cv_HAVE___VA_COPY,[ -AC_TRY_LINK([#include <stdarg.h> -va_list ap1,ap2;], [__va_copy(ap1,ap2);], -dbench_cv_HAVE___VA_COPY=yes,dbench_cv_HAVE___VA_COPY=no)]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h> +va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],[dbench_cv_HAVE___VA_COPY=yes],[dbench_cv_HAVE___VA_COPY=no])]) if test x"$dbench_cv_HAVE___VA_COPY" = x"yes"; then AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available]) fi
@@ -83,7 +94,7 @@ ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$GLIB_LIBS $LIBS -lpopt" -AC_TRY_RUN([ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* * Just see if we can compile/link with popt */
@@ -98,8 +109,7 @@ int main(int argc, const char *argv[]) return 0; } -], ac_cv_have_popt=yes, ac_cv_have_popt=no, - [echo $ac_n "compile with POPT. Assuming OK... $ac_c" +]])],[ac_cv_have_popt=yes],[ac_cv_have_popt=no],[echo $ac_n "compile with POPT. Assuming OK... $ac_c" ac_cv_have_popt=yes]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS"
@@ -119,7 +129,7 @@ ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$GLIB_LIBS $LIBS -lsmbclient" -AC_TRY_RUN([ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <stdio.h> #include <libsmbclient.h>
@@ -137,8 +147,7 @@ int main(int argc, char *argv[]) return 0; } -], ac_cv_have_libsmbclient=yes, ac_cv_have_libsmbclient=no, - [echo $ac_n "compile with LIBSMBCLIENT. Assuming OK... $ac_c" +]])],[ac_cv_have_libsmbclient=yes],[ac_cv_have_libsmbclient=no],[echo $ac_n "compile with LIBSMBCLIENT. Assuming OK... $ac_c" ac_cv_have_libsmbclient=yes]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS"
@@ -162,7 +171,7 @@ ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$GLIB_LIBS $LIBS -liscsi" -AC_TRY_RUN([ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <stdio.h> #include <iscsi/iscsi.h>
@@ -180,8 +189,7 @@ int main(int argc, char *argv[]) return 0; } -], ac_cv_have_libiscsi=yes, ac_cv_have_libiscsi=no, - [echo $ac_n "compile with LIBISCSI. Assuming OK... $ac_c" +]])],[ac_cv_have_libiscsi=yes],[ac_cv_have_libiscsi=no],[echo $ac_n "compile with LIBISCSI. Assuming OK... $ac_c" ac_cv_have_libiscsi=yes]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS"
@@ -203,7 +211,7 @@ ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$GLIB_LIBS $LIBS" -AC_TRY_RUN([ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* We can only check that this program compiles. We cant check whether the actual ioctl works since opening the device and doing i/o can only be done by root.
@@ -229,8 +237,7 @@ int main(int argc, char *argv[]) return 0; } -], ac_cv_linux_scsi_sg=yes, ac_cv_linux_scsi_sg=no, - [echo $ac_n "cross compiling; assumed OK... $ac_c" +]])],[ac_cv_linux_scsi_sg=yes],[ac_cv_linux_scsi_sg=no],[echo $ac_n "cross compiling; assumed OK... $ac_c" ac_cv_linux_scsi_sg=yes]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS"
Signature · 1 line
2.34.1
PATCH 7/25 dbench: update use of time.h or sys/time.h
In reply to Luis Chamberlainautoconf complains about the deprecated use of including just sys/time.h. Fix this.
--- configure.ac | 16 +--------------- dbench.h | 13 ++++++++++++- 2 files changed, 13 insertions(+), 16 deletions(-)
configure.ac +1 -15
@@ -23,27 +23,13 @@ else CFLAGS="$CFLAGS -O" fi -AC_HEADER_DIRENT -m4_warn([obsolete], -[Update your code to rely only on HAVE_SYS_TIME_H, -then remove this warning and the obsolete code below it. -All current systems provide time.h; it need not be checked for. -Not all systems provide sys/time.h, but those that do, all allow -you to include it and time.h simultaneously.])dnl -AC_CHECK_HEADERS_ONCE([sys/time.h]) -# Obsolete code to be removed. -if test $ac_cv_header_sys_time_h = yes; then - AC_DEFINE([TIME_WITH_SYS_TIME],[1],[Define to 1 if you can safely include both <sys/time.h> - and <time.h>. This macro is obsolete.]) -fi -# End of obsolete code. - AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h sys/vfs.h sys/statvfs.h stdint.h) AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h) AC_CHECK_HEADERS(sys/mount.h) +AC_CHECK_HEADERS([sys/time.h]) AC_CHECK_FUNCS(fdatasync) # Check if we have libattr
dbench.h +12 -1
@@ -27,7 +27,18 @@#include <ctype.h> #include <dirent.h> #include <sys/stat.h> -#include <sys/time.h> + +#ifdef TIME_WITH_SYS_TIME +# include <sys/time.h> +# include <time.h> +#else +# ifdef HAVE_SYS_TIME_H +# include <sys/time.h> +# else +# include <time.h> +# endif +#endif +#include <sys/wait.h> #include <sys/types.h> #include <sys/socket.h>
Signature · 1 line
2.34.1
PATCH 8/25 config.h.in: run autoconf
In reply to Luis Chamberlain--- config.h.in | 19 ------------------- 1 file changed, 19 deletions(-)
config.h.in +0 -19
@@ -33,10 +33,6 @@ /* Define to 1 if you have the <ctype.h> header file. */ #undef HAVE_CTYPE_H -/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. - */ -#undef HAVE_DIRENT_H - /* Whether we have EA support */ #undef HAVE_EA_SUPPORT
@@ -121,9 +117,6 @@ /* Define to 1 if you have the `lsetxattr' function. */ #undef HAVE_LSETXATTR -/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ -#undef HAVE_NDIR_H - /* Define to 1 if you have the `removexattr' function. */ #undef HAVE_REMOVEXATTR
@@ -151,20 +144,12 @@ /* Define to 1 if you have the <sys/attributes.h> header file. */ #undef HAVE_SYS_ATTRIBUTES_H -/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. - */ -#undef HAVE_SYS_DIR_H - /* Define to 1 if you have the <sys/extattr.h> header file. */ #undef HAVE_SYS_EXTATTR_H /* Define to 1 if you have the <sys/mount.h> header file. */ #undef HAVE_SYS_MOUNT_H -/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. - */ -#undef HAVE_SYS_NDIR_H - /* Define to 1 if you have the <sys/statvfs.h> header file. */ #undef HAVE_SYS_STATVFS_H
@@ -227,9 +212,5 @@ backward compatibility; new code need not use it. */ #undef STDC_HEADERS -/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. This - macro is obsolete. */ -#undef TIME_WITH_SYS_TIME - /* Define _GNU_SOURCE so that we get all necessary prototypes */ #undef _GNU_SOURCE
Signature · 1 line
2.34.1
PATCH 9/25 snprintf: specify safe fallthrough on switches
In reply to Luis Chamberlaingcc -Wall will complain when we fallthrough on a switch but don't mean it. Fortunately we can follow the Linux kernel strategy to use -Wimplicit-fallthrough=2 and allow comments to supress this to clarify this was intended.
--- Makefile.in | 4 +++- snprintf.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)
Makefile.in +3 -1
@@ -16,6 +16,8 @@ DESTDIR=/ CC=@CC@ CFLAGS=@CFLAGS@ -I. -DVERSION=\"$(VERSION)\" -DDATADIR=\"$(datadir)\" CFLAGS+=`pkg-config --cflags libtirpc` +# Allows comments to be used for fallthrough +CFLAGS+=-Wimplicit-fallthrough=2 CFLAGS_RPCGEN=-Wno-unused-variable LIBS+=`pkg-config --libs libtirpc` EXEEXT=@EXEEXT@
@@ -28,7 +30,7 @@ SRV_OBJS = util.o tbench_srv.o socklib.o all: dbench doc dbench: $(DB_OBJS) - $(CC) -o $@ $(DB_OBJS) $(LIBS) + $(CC) $(CFLAGS) -o $@ $(DB_OBJS) $(LIBS) tbench_srv: $(SRV_OBJS) $(CC) -o $@ $(SRV_OBJS) $(LIBS)
snprintf.c +3 -0
@@ -317,6 +317,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list argsbreak ;case 'X' : flags |=DP_F_UP ; +/* fallthrough */ case 'x' : flags |=DP_F_UNSIGNED ;if (cflags ==DP_C_SHORT )
@@ -339,6 +340,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list argsbreak ;case 'E' : flags |=DP_F_UP ; +/* fallthrough */ case 'e' :if (cflags ==DP_C_LDOUBLE ) fvalue =va_arg (args,LDOUBLE );
@@ -348,6 +350,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list argsbreak ;case 'G' : flags |=DP_F_UP ; +/* fallthrough */ case 'g' :if (cflags ==DP_C_LDOUBLE ) fvalue =va_arg (args,LDOUBLE );
Signature · 1 line
2.34.1
PATCH 10/25 nfsio.c: include dbench.h before nfs.h
In reply to Luis ChamberlainThis is so _GNU_SOURCE is defined so asprintf() is declared when including <stdio.h>.
--- nfsio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
nfsio.c +1 -1
@@ -17,8 +17,8 @@#define _FILE_OFFSET_BITS 64 -#include "nfs.h" #include "dbench.h" +#include "nfs.h" #include <stdio.h> #include "mount.h"
Signature · 1 line
2.34.1
PATCH 11/25 nfsio: remove unused status variable
In reply to Luis Chamberlain--- nfsio.c | 1 - 1 file changed, 1 deletion(-)
nfsio.c +0 -1
@@ -51,7 +51,6 @@ static void nfs3_cleanup(struct child_struct *child)static void nfs3_setup (struct child_struct *child) { -const char *status ="0x00000000" ;nfsstat3 res; child->rate.last_time =timeval_current ();
Signature · 1 line
2.34.1
PATCH 12/25 child: be expicit about string truncation goal
In reply to Luis ChamberlainFix this compilation warning:
child.c:260:9: warning: ‘strncpy’ specified bound 256 equals destination size [-Wstringop-truncation]
260 | strncpy(str, pstart, sizeof(str));
We do this by being explicit about our goal to truncate or use the smaller string passed.
--- child.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
child.c +5 -1
@@ -251,13 +251,17 @@ static int parse_randomstring(char *line)char *pstart, *pend, rndc[2 ];unsigned int idx;char str[256 ]; +size_t min_len; again: pstart =index (line,'[' );if (pstart ==NULL ) { goto finished; } -strncpy (str, pstart,sizeof (str)); + +/* Truncate or use the smaller size passed */ + min_len =strlen (line) <sizeof (str) ?strlen (line) :sizeof (str); +strncpy (str, pstart, min_len); pend =index (str,']' );if (pstart ==NULL ) {
Signature · 1 line
2.34.1
PATCH 13/25 child: do not overlap on memcpy()
In reply to Luis ChamberlainFix this compilation warning:
gcc -g -O2 -Wall -W -I. -DVERSION=\"4.00\" -DDATADIR=\"/usr/local/share\" pkg-config --cflags libtirpc
-Wimplicit-fallthrough=2 -c -o child.o child.c
In function ‘parse_randomstring’,
inlined from ‘child_run’ at child.c:465:8:
child.c:291:17: warning: ‘memcpy’ accessing 255 bytes at offsets 0 and 1 overlaps 254 bytes at offset 1 [-Wrestrict]
291 | memcpy(str, str+1, sizeof(str)-1);
We fix this by using a copy of the string to a original string so to avoid having memcpy() overlap.
--- child.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
child.c +3 -1
@@ -250,6 +250,7 @@ static int parse_randomstring(char *line)int num;char *pstart, *pend, rndc[2 ];unsigned int idx; +char str_orig[256 ];char str[256 ];size_t min_len;
@@ -262,6 +263,7 @@ again:/* Truncate or use the smaller size passed */ min_len =strlen (line) <sizeof (str) ?strlen (line) :sizeof (str);strncpy (str, pstart, min_len); +strncpy (str_orig, pstart, min_len); pend =index (str,']' );if (pstart ==NULL ) {
@@ -288,7 +290,7 @@ finished: }/* remote initial " */ while (str[0 ] =='"' ) { -memcpy (str, str+1 ,sizeof (str)-1 ); +memcpy (str, str_orig+1 ,sizeof (str_orig)-1 ); }/* remote trailing " */ while (1 ) {
Signature · 1 line
2.34.1
PATCH 14/25 dbench.h: use bits/types.h instead of defining uint32
In reply to Luis ChamberlainThis fixes this compilation warning:
Compiling nfsio.o
gcc -g -g -O2 -Wall -W -I. -DVERSION=\"4.00\" -DDATADIR=\"/usr/local/share\" pkg-config --cflags libtirpc -Wimplicit-fallthrough=2 -c nfsio.c -o nfsio.o
In file included from nfsio.c:20:
dbench.h:105:16: error: two or more data types in declaration specifiers
105 | #define uint32 unsigned int
| ^~~~~~~~
nfs.h:54:16: note: in expansion of macro ‘uint32’
54 | typedef u_long uint32;
| ^~~~~~dbench.h:105:25: error: two or more data types in declaration specifiers
105 | #define uint32 unsigned int
| ^~~
nfs.h:54:16: note: in expansion of macro ‘uint32’
54 | typedef u_long uint32;
| ^~~~~~
In file included from nfsio.c:21:
nfs.h:54:1: warning: useless type name in empty declaration
54 | typedef u_long uint32;
| ^~~~~~~--- dbench.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
dbench.h +2 -1
@@ -102,7 +102,8 @@#define BOOL int#define True 1#define False 0 -#define uint32 unsigned + +#include <bits/types.h> struct op {unsigned count;
Signature · 1 line
2.34.1
PATCH 15/25 sockio.c: use uint32_t
In reply to Luis ChamberlainAvoid the ambiguous uint32.
--- sockio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sockio.c +1 -1
@@ -29,7 +29,7 @@ struct sockio {static void do_packets (struct child_struct *child,int send_size,int recv_size) {struct sockio *sockio = (struct sockio *)child->private; -uint32 *ubuf = (uint32 *)sockio->buf; +uint32_t *ubuf = (uint32_t *)sockio->buf; ubuf[0 ] =htonl (send_size-4 ); ubuf[1 ] =htonl (recv_size-4 );
Signature · 1 line
2.34.1
PATCH 16/25 libnfs.c: fix a few simple compile warnings
In reply to Luis ChamberlainLike including dbench.h first so GNUSOURCE is defined and return is not needed.
--- libnfs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
libnfs.c +3 -4
@@ -17,10 +17,11 @@along with this program; if not, see <http://www.gnu.org/licenses/>. */ #define _FILE_OFFSET_BITS 64 -#include <thread_db.h> +#include "dbench.h" #include "mount.h" #include "nfs.h" #include "libnfs.h" +#include <thread_db.h> #include <stdint.h> #include <sys/types.h> #include <sys/stat.h>
@@ -123,8 +124,7 @@ static data_t *recursive_lookup_fhandle(struct nfsio *nfsio, const char *name)if (t !=NULL ) {return &t->fh; } - -return ; +return NULL ; }static data_t *lookup_fhandle (struct nfsio *nfsio,const char *name,off_t *off)
@@ -392,7 +392,6 @@ struct nfsio *nfsio_connect(const char *server, const char *export, const char *mountres3 *mountres;fhandle3 *fh;struct sockaddr_in sin; -int ret; nfsio =malloc (sizeof (struct nfsio ));if (nfsio ==NULL ) {
Signature · 1 line
2.34.1
PATCH 17/25 libnfs: fix compilation warning for inet_tons
In reply to Luis Chamberlain--- libnfs.c | 4 ++++ 1 file changed, 4 insertions(+)
libnfs.c +4 -0
@@ -27,6 +27,10 @@#include <sys/stat.h> #include <fcntl.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#define discard_const (ptr) ((void *)((intptr_t)(ptr))) typedef struct _data_t {
Signature · 1 line
2.34.1
PATCH 18/25 libnfs.c: fix sign conflict compile warning
In reply to Luis Chamberlain--- libnfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
libnfs.c +2 -2
@@ -853,10 +853,10 @@ nfsstat3 nfsio_read(struct nfsio *nfsio, const char *name, char *buf, uint64_t o goto finished; } -if (offset >= size && size >0 ) { +if (offset >= (uint64_t ) size && (uint64_t ) size >0 ) { offset = offset % size; } -if (offset+len >= size) { +if (offset+len >= (uint64_t ) size) { offset =0 ; }
Signature · 1 line
2.34.1
PATCH 19/25 Makefile.in:
In reply to Luis Chamberlainmount_client.c:19:17: warning: cast between incompatible function types from ‘bool_t (*)(void)’ {aka ‘int (*)(void)’} to ‘bool_t (*)(XDR *, ...)’ {aka ‘int (*)(struct __rpc_xdr *, ...)’} [-Wcast-function-type]
19 | (xdrproc_t) xdr_void, (caddr_t) argp,
| ^--- Makefile.in | 1 + 1 file changed, 1 insertion(+)
Makefile.in +1 -0
@@ -19,6 +19,7 @@ CFLAGS+=`pkg-config --cflags libtirpc` # Allows comments to be used for fallthrough CFLAGS+=-Wimplicit-fallthrough=2 CFLAGS_RPCGEN=-Wno-unused-variable +CFLAGS_RPCGEN+=-Wno-cast-function-type LIBS+=`pkg-config --libs libtirpc` EXEEXT=@EXEEXT@
Signature · 1 line
2.34.1
PATCH 20/25 linux_scsi.c: fix redeclaration of _GNU_SOURCE
In reply to Luis Chamberlain--- linux_scsi.c | 4 ---- 1 file changed, 4 deletions(-)
linux_scsi.c +0 -4
@@ -16,10 +16,6 @@*/ #include "dbench.h" -#define _GNU_SOURCE -#include <stdio.h> -#undef _GNU_SOURCE -#include <fcntl.h> #include <sys/ioctl.h> #include <scsi/sg.h>
Signature · 1 line
2.34.1
PATCH 21/25 Makefile.in: modernize build output with V=1 or V=0
In reply to Luis ChamberlainAllow the build to be chatty or not. By default we're quiet.
--- Makefile.in | 120 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 50 deletions(-)
Makefile.in +70 -50
@@ -28,99 +28,119 @@ LIBNFS_OBJ = libnfs.o mount_client.o nfs_client.o mount_xdr.o nfs_xdr.o DB_OBJS = fileio.o util.o dbench.o child.o system.o snprintf.o sockio.o nfsio.o libnfs.a socklib.o @LINUXSCSI@ iscsi.o libiscsi.o @SMBO@ SRV_OBJS = util.o tbench_srv.o socklib.o +ifeq ($(V),1) + export Q= + export NQ=true +else + export Q=@ + export NQ=@echo +endif + all: dbench doc +%.o: %.c dbench.h + $(NQ) ' CC ' $@ + $(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< + dbench: $(DB_OBJS) - $(CC) $(CFLAGS) -o $@ $(DB_OBJS) $(LIBS) + $(NQ) ' LD ' $@ + $(Q)$(CC) $(CFLAGS) -o $@ $(DB_OBJS) $(LIBS) tbench_srv: $(SRV_OBJS) - $(CC) -o $@ $(SRV_OBJS) $(LIBS) + $(NQ) ' CC ' $@ + $(Q)$(CC) -o $@ $(SRV_OBJS) $(LIBS) tbench: dbench - ln -sf dbench tbench + $(NQ) ' LN ' $@ + $(Q)ln -sf dbench tbench libnfs.a: $(LIBNFS_OBJ) - @echo Creating library $@ - ar r libnfs.a $(LIBNFS_OBJ) - ranlib libnfs.a + $(NQ) ' AR ' $@ + $(Q)ar r libnfs.a $(LIBNFS_OBJ) + $(Q)ranlib libnfs.a nfsio.o: nfsio.c mount.h nfs.h - @echo Compiling $@ - gcc -g $(CFLAGS) -c nfsio.c -o $@ + $(NQ) ' CC ' $@ + $(Q)gcc -g $(CFLAGS) -c nfsio.c -o $@ libnfs.o: libnfs.c libnfs.h mount.h nfs.h - @echo Compiling $@ - gcc -g $(CFLAGS) -c libnfs.c -o $@ + $(NQ) ' CC ' $@ + $(Q)gcc -g $(CFLAGS) -c libnfs.c -o $@ mount.h: mount.x - @echo Generating $@ - rpcgen -h mount.x > mount.h + $(NQ) ' RPCGEN ' $@ + $(Q)rpcgen -h mount.x > mount.h nfs.h: nfs.x - @echo Generating $@ - rpcgen -h nfs.x > nfs.h + $(NQ) ' CC ' $@ + $(Q)rpcgen -h nfs.x > nfs.h mount_xdr.o: mount_xdr.c mount.h - @echo Compiling $@ - gcc -g $(CFLAGS) $(CFLAGS_RPCGEN) -c mount_xdr.c -o $@ + $(NQ) ' CC ' $@ + $(Q)gcc -g $(CFLAGS) $(CFLAGS_RPCGEN) -c mount_xdr.c -o $@ mount_xdr.c: mount.x - @echo Generating $@ - rpcgen -c mount.x > mount_xdr.c + $(NQ) ' RPCGEN ' $@ + $(Q)rpcgen -c mount.x > mount_xdr.c mount_client.o: mount_client.c mount.h - @echo Compiling $@ - gcc -g $(CFLAGS) $(CFLAGS_RPCGEN) -c mount_client.c -o $@ + $(NQ) ' CC ' $@ + $(Q)gcc -g $(CFLAGS) $(CFLAGS_RPCGEN) -c mount_client.c -o $@ mount_client.c: mount.x - @echo Generating $@ - rpcgen -l mount.x > mount_client.c + $(NQ) ' RPCGEN ' $@ + $(Q)rpcgen -l mount.x > mount_client.c nfs_xdr.o: nfs_xdr.c nfs.h - @echo Compiling $@ - gcc $(CFLAGS) $(CFLAGS_RPCGEN) -g -c nfs_xdr.c -o $@ + $(NQ) ' CC ' $@ + $(Q)gcc $(CFLAGS) $(CFLAGS_RPCGEN) -g -c nfs_xdr.c -o $@ nfs_xdr.c: nfs.x - @echo Generating $@ - rpcgen -c nfs.x > nfs_xdr.c + $(NQ) ' RPCGEN ' $@ + $(Q)rpcgen -c nfs.x > nfs_xdr.c nfs_client.o: nfs_client.c nfs.h - @echo Compiling $@ - gcc -g $(CFLAGS) $(CFLAGS_RPCGEN) -c nfs_client.c -o $@ + $(NQ) ' CC ' $@ + $(Q)gcc -g $(CFLAGS) $(CFLAGS_RPCGEN) -c nfs_client.c -o $@ nfs_client.c: nfs.x - @echo Generating $@ - rpcgen -l nfs.x > nfs_client.c + $(NQ) ' RPCGEN ' $@ + $(Q)rpcgen -l nfs.x > nfs_client.c doc/dbench.1.html: doc/dbench.1.xml - -test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl $< + $(NQ) 'GEN-HTML ' $@ + $(Q)-test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl $< doc/dbench.1: doc/dbench.1.xml - -test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $< + $(NQ) 'GEN-MAN ' $@ + $(Q)-test -z "$(XSLTPROC)" || $(XSLTPROC) -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $< doc: doc/dbench.1 doc/dbench.1.html # Careful here: don't install client.txt over itself. install: all - mkdir -p $(DESTDIR)$(bindir) - mkdir -p $(DESTDIR)$(docdir)/loadfiles - mkdir -p $(DESTDIR)$(mandir)/man1 - ${INSTALLCMD} dbench $(DESTDIR)$(bindir) - ${INSTALLCMD} loadfiles/client.txt $(DESTDIR)$(docdir)/loadfiles - ${INSTALLCMD} loadfiles/nfs.txt $(DESTDIR)$(docdir)/loadfiles - ${INSTALLCMD} loadfiles/nfs_2.txt $(DESTDIR)$(docdir)/loadfiles - ${INSTALLCMD} loadfiles/smb.txt $(DESTDIR)$(docdir)/loadfiles - ${INSTALLCMD} loadfiles/smb_1.txt $(DESTDIR)$(docdir)/loadfiles - ${INSTALLCMD} loadfiles/smb_2.txt $(DESTDIR)$(docdir)/loadfiles - ${INSTALLCMD} loadfiles/smb_3.txt $(DESTDIR)$(docdir)/loadfiles - ${INSTALLCMD} loadfiles/iscsi.txt $(DESTDIR)$(docdir)/loadfiles - ${INSTALLCMD} loadfiles/scsi.txt $(DESTDIR)$(docdir)/loadfiles - ${INSTALLCMD} -m644 dbench.1 $(DESTDIR)$(mandir)/man1 + $(NQ) ' INSTALL ' $@ + $(Q)mkdir -p $(DESTDIR)$(bindir) + $(Q)mkdir -p $(DESTDIR)$(docdir)/loadfiles + $(Q)(mkdir -p $(DESTDIR)$(mandir)/man1 + $(Q)${INSTALLCMD} dbench $(DESTDIR)$(bindir) + $(Q)${INSTALLCMD} loadfiles/client.txt $(DESTDIR)$(docdir)/loadfiles + $(Q)${INSTALLCMD} loadfiles/nfs.txt $(DESTDIR)$(docdir)/loadfiles + $(Q)${INSTALLCMD} loadfiles/nfs_2.txt $(DESTDIR)$(docdir)/loadfiles + $(Q)${INSTALLCMD} loadfiles/smb.txt $(DESTDIR)$(docdir)/loadfiles + $(Q)${INSTALLCMD} loadfiles/smb_1.txt $(DESTDIR)$(docdir)/loadfiles + $(Q)${INSTALLCMD} loadfiles/smb_2.txt $(DESTDIR)$(docdir)/loadfiles + $(Q)${INSTALLCMD} loadfiles/smb_3.txt $(DESTDIR)$(docdir)/loadfiles + $(Q)${INSTALLCMD} loadfiles/iscsi.txt $(DESTDIR)$(docdir)/loadfiles + $(Q)${INSTALLCMD} loadfiles/scsi.txt $(DESTDIR)$(docdir)/loadfiles + $(Q)${INSTALLCMD} -m644 dbench.1 $(DESTDIR)$(mandir)/man1 clean: - rm -f *.[ao] *~ dbench tbench_srv - rm -f mount.h mount_xdr.c mount_client.c - rm -f nfs.h nfs_xdr.c nfs_client.c + $(NQ) ' CLEAN ' $@ + $(Q)rm -f *.[ao] *~ dbench tbench_srv + $(Q)rm -f mount.h mount_xdr.c mount_client.c + $(Q)rm -f nfs.h nfs_xdr.c nfs_client.c proto: - ./mkproto.pl *.c > proto.h + $(NQ) ' MKPROTO ' $@ + $(Q)./mkproto.pl *.c > proto.h
Signature · 1 line
2.34.1
PATCH 22/25 Makefile.in: declare datarootdir
In reply to Luis ChamberlainThis shuts up a complaint from ./configure
--- Makefile.in | 1 + 1 file changed, 1 insertion(+)
Makefile.in +1 -0
@@ -4,6 +4,7 @@ srcdir=@srcdir@ VPATH=@srcdir@ prefix=@prefix@ +datarootdir = @datarootdir@ exec_prefix=@exec_prefix@ bindir=@bindir@ mandir=@mandir@
Signature · 1 line
2.34.1
PATCH 23/25 configure.ac: fix smbclient detection
In reply to Luis ChamberlainWe need to ask smbclient for the cflags, otherwise the headers won't be found.
--- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configure.ac +1 -1
@@ -113,7 +113,7 @@ fi AC_MSG_CHECKING(whether libsmbclient is available) ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" -CFLAGS="$CFLAGS $GLIB_CFLAGS" +CFLAGS="$CFLAGS $GLIB_CFLAGS $(pkg-config --cflags smbclient)" LIBS="$GLIB_LIBS $LIBS -lsmbclient" AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <stdio.h>
Signature · 1 line
2.34.1
PATCH 24/25 libiscsi: fix compile warning on data types
In reply to Luis ChamberlainThis fixes this compilation warning:
libiscsi.c: In function ‘iscsi_write10’:
libiscsi.c:119:40: warning: pointer targets in passing argument 4 of ‘iscsi_write10_sync’ differ in signedness [-Wpointer-sign]
119 | data, xferlen*512, 512,
| ^~~~
| |
| char *In file included from libiscsi.c:26:/usr/include/iscsi/iscsi.h:1200:35: note: expected ‘unsigned char *’ but argument is of type ‘char *’
1200 | unsigned char *data, uint32_t datalen, int
blocksize,
| ~~~~~~~~~~~~~~~^~~~CC
--- libiscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libiscsi.c +1 -1
@@ -99,7 +99,7 @@ static void iscsi_write10(struct dbench_op *op)uint32_t xferlen = op->params[1 ];int fua = op->params[2 ];unsigned int data_size=1024 *1024 ; -char data[data_size]; +unsigned char data[data_size]; sd = op->child->private;
Signature · 1 line
2.34.1
PATCH 25/25 smb: fix compilation and disable warning on deprecated-declarations
In reply to Luis Chamberlainsmb.c hasn't been updated in a while, so disable warning on deprecated-declarations for now. An smb eager beaver can go fix this.
--- Makefile.in | 6 ++++++ 1 file changed, 6 insertions(+)
Makefile.in +6 -0
@@ -21,6 +21,8 @@ CFLAGS+=`pkg-config --cflags libtirpc` CFLAGS+=-Wimplicit-fallthrough=2 CFLAGS_RPCGEN=-Wno-unused-variable CFLAGS_RPCGEN+=-Wno-cast-function-type +SMBCFLAGS=-Wno-deprecated-declarations +SMBCFLAGS+=`pkg-config --cflags smbclient` LIBS+=`pkg-config --libs libtirpc` EXEEXT=@EXEEXT@
@@ -68,6 +70,10 @@ libnfs.o: libnfs.c libnfs.h mount.h nfs.h $(NQ) ' CC ' $@ $(Q)gcc -g $(CFLAGS) -c libnfs.c -o $@ +smb.o: smb.c dbench.h + $(NQ) ' CC ' $@ + $(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) $(SMBCFLAGS) -o $@ $< + mount.h: mount.x $(NQ) ' RPCGEN ' $@ $(Q)rpcgen -h mount.x > mount.h
Signature · 1 line
2.34.1