Fix various compiler warnings. filelist-order.cxx:57:31: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings] filelist-order.cxx:89:1: warning: ‘typedef’ was ignored in this declaration filelist-order.cxx:98:69: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] et al. --- a/src/filelist-order.cxx +++ b/src/filelist-order.cxx @@ -53,9 +53,9 @@ int __STACK_DEBUG__ = 0; using namespace std; -static char* program_name = "filelist-order"; -static char* program_header = "$Header: /var/cvsroot/infrastructure/readahead-list/src/filelist-order.cxx,v 1.6 2005/05/17 02:12:43 robbat2 Exp $"; -static char* program_id = "$Id: filelist-order.cxx,v 1.6 2005/05/17 02:12:43 robbat2 Exp $"; +static const char* program_name = "filelist-order"; +static const char* program_header = "$Header: /var/cvsroot/infrastructure/readahead-list/src/filelist-order.cxx,v 1.6 2005/05/17 02:12:43 robbat2 Exp $"; +static const char* program_id = "$Id: filelist-order.cxx,v 1.6 2005/05/17 02:12:43 robbat2 Exp $"; static int flag_input_file = 0; static int flag_input_stdin = 0; @@ -75,7 +75,7 @@ static struct option long_options[] = { {"fields", 1, &flag_fields, 1}, {0, 0, 0, 0} }; -static char* short_options = "f:vdhV"; +static const char* short_options = "f:vdhV"; // 64-bit integers are needed for some fields #define BASE_DATATYPE long long int @@ -86,7 +86,7 @@ struct mapkey { char* filename; }; -typedef enum OrderField_Type { ST_DEV,ST_INO,ST_MODE,ST_NLINK,ST_UID,ST_GID,ST_RDEV,ST_SIZE,ST_BLKSIZE,ST_BLOCKS,ST_ATIME,ST_MTIME,ST_CTIME,IOCTL_FIBMAP,FILENAME }; +enum OrderField_Type { ST_DEV,ST_INO,ST_MODE,ST_NLINK,ST_UID,ST_GID,ST_RDEV,ST_SIZE,ST_BLKSIZE,ST_BLOCKS,ST_ATIME,ST_MTIME,ST_CTIME,IOCTL_FIBMAP,FILENAME }; struct OrderField { OrderField_Type type; bool reverse; @@ -95,7 +95,7 @@ struct OrderField { } }; -inline const int numcmp(const BASE_DATATYPE a, const BASE_DATATYPE b) { +inline int numcmp(const BASE_DATATYPE a, const BASE_DATATYPE b) { DEBUG_STACK_UP; DEBUG("%s\n","numcmp-init"); int ret = 0; @@ -109,39 +109,39 @@ inline const int numcmp(const BASE_DATATYPE a, const BASE_DATATYPE b) { return ret; } -inline const BASE_DATATYPE func_ST_DEV(mapkey a) { return ((a).sb->st_dev); } -inline const BASE_DATATYPE func_ST_INO(mapkey a) { return ((a).sb->st_ino); } -inline const BASE_DATATYPE func_ST_MODE(mapkey a) { return ((a).sb->st_mode); } -inline const BASE_DATATYPE func_ST_NLINK(mapkey a) { return ((a).sb->st_nlink); } -inline const BASE_DATATYPE func_ST_UID(mapkey a) { return ((a).sb->st_uid); } -inline const BASE_DATATYPE func_ST_GID(mapkey a) { return ((a).sb->st_gid); } -inline const BASE_DATATYPE func_ST_RDEV(mapkey a) { return ((a).sb->st_rdev); } -inline const BASE_DATATYPE func_ST_SIZE(mapkey a) { return ((a).sb->st_size); } -inline const BASE_DATATYPE func_ST_BLKSIZE(mapkey a) { return ((a).sb->st_blksize); } -inline const BASE_DATATYPE func_ST_BLOCKS(mapkey a) { return ((a).sb->st_blocks); } -inline const BASE_DATATYPE func_ST_ATIME(mapkey a) { return ((a).sb->st_atime); } -inline const BASE_DATATYPE func_ST_MTIME(mapkey a) { return ((a).sb->st_mtime); } -inline const BASE_DATATYPE func_ST_CTIME(mapkey a) { return ((a).sb->st_ctime); } -inline const BASE_DATATYPE func_IOCTL_FIBMAP(mapkey a) { return ((a).first_block); } -inline const char* func_FILENAME(mapkey a) { return ((a).filename); } - - -inline const int cmp_ST_DEV(mapkey a, mapkey b) { return numcmp(func_ST_DEV(a),func_ST_DEV(b)); } -inline const int cmp_ST_INO(mapkey a, mapkey b) { return numcmp(func_ST_INO(a),func_ST_INO(b)); } -inline const int cmp_ST_MODE(mapkey a, mapkey b) { return numcmp(func_ST_MODE(a),func_ST_MODE(b)); } -inline const int cmp_ST_NLINK(mapkey a, mapkey b) { return numcmp(func_ST_NLINK(a),func_ST_NLINK(b)); } -inline const int cmp_ST_UID(mapkey a, mapkey b) { return numcmp(func_ST_UID(a),func_ST_UID(b)); } -inline const int cmp_ST_GID(mapkey a, mapkey b) { return numcmp(func_ST_GID(a),func_ST_GID(b)); } -inline const int cmp_ST_RDEV(mapkey a, mapkey b) { return numcmp(func_ST_RDEV(a),func_ST_RDEV(b)); } -inline const int cmp_ST_SIZE(mapkey a, mapkey b) { return numcmp(func_ST_SIZE(a),func_ST_SIZE(b)); } -inline const int cmp_ST_BLKSIZE(mapkey a, mapkey b) { return numcmp(func_ST_BLKSIZE(a),func_ST_BLKSIZE(b)); } -inline const int cmp_ST_BLOCKS(mapkey a, mapkey b) { return numcmp(func_ST_BLOCKS(a),func_ST_BLOCKS(b)); } -inline const int cmp_ST_ATIME(mapkey a, mapkey b) { return numcmp(func_ST_ATIME(a),func_ST_ATIME(b)); } -inline const int cmp_ST_MTIME(mapkey a, mapkey b) { return numcmp(func_ST_MTIME(a),func_ST_MTIME(b)); } -inline const int cmp_ST_CTIME(mapkey a, mapkey b) { return numcmp(func_ST_CTIME(a),func_ST_CTIME(b)); } -inline const int cmp_IOCTL_FIBMAP(mapkey a, mapkey b) { return numcmp(func_IOCTL_FIBMAP(a),func_IOCTL_FIBMAP(b)); } +inline BASE_DATATYPE func_ST_DEV(mapkey a) { return ((a).sb->st_dev); } +inline BASE_DATATYPE func_ST_INO(mapkey a) { return ((a).sb->st_ino); } +inline BASE_DATATYPE func_ST_MODE(mapkey a) { return ((a).sb->st_mode); } +inline BASE_DATATYPE func_ST_NLINK(mapkey a) { return ((a).sb->st_nlink); } +inline BASE_DATATYPE func_ST_UID(mapkey a) { return ((a).sb->st_uid); } +inline BASE_DATATYPE func_ST_GID(mapkey a) { return ((a).sb->st_gid); } +inline BASE_DATATYPE func_ST_RDEV(mapkey a) { return ((a).sb->st_rdev); } +inline BASE_DATATYPE func_ST_SIZE(mapkey a) { return ((a).sb->st_size); } +inline BASE_DATATYPE func_ST_BLKSIZE(mapkey a) { return ((a).sb->st_blksize); } +inline BASE_DATATYPE func_ST_BLOCKS(mapkey a) { return ((a).sb->st_blocks); } +inline BASE_DATATYPE func_ST_ATIME(mapkey a) { return ((a).sb->st_atime); } +inline BASE_DATATYPE func_ST_MTIME(mapkey a) { return ((a).sb->st_mtime); } +inline BASE_DATATYPE func_ST_CTIME(mapkey a) { return ((a).sb->st_ctime); } +inline BASE_DATATYPE func_IOCTL_FIBMAP(mapkey a) { return ((a).first_block); } +inline char* func_FILENAME(mapkey a) { return ((a).filename); } + + +inline int cmp_ST_DEV(mapkey a, mapkey b) { return numcmp(func_ST_DEV(a),func_ST_DEV(b)); } +inline int cmp_ST_INO(mapkey a, mapkey b) { return numcmp(func_ST_INO(a),func_ST_INO(b)); } +inline int cmp_ST_MODE(mapkey a, mapkey b) { return numcmp(func_ST_MODE(a),func_ST_MODE(b)); } +inline int cmp_ST_NLINK(mapkey a, mapkey b) { return numcmp(func_ST_NLINK(a),func_ST_NLINK(b)); } +inline int cmp_ST_UID(mapkey a, mapkey b) { return numcmp(func_ST_UID(a),func_ST_UID(b)); } +inline int cmp_ST_GID(mapkey a, mapkey b) { return numcmp(func_ST_GID(a),func_ST_GID(b)); } +inline int cmp_ST_RDEV(mapkey a, mapkey b) { return numcmp(func_ST_RDEV(a),func_ST_RDEV(b)); } +inline int cmp_ST_SIZE(mapkey a, mapkey b) { return numcmp(func_ST_SIZE(a),func_ST_SIZE(b)); } +inline int cmp_ST_BLKSIZE(mapkey a, mapkey b) { return numcmp(func_ST_BLKSIZE(a),func_ST_BLKSIZE(b)); } +inline int cmp_ST_BLOCKS(mapkey a, mapkey b) { return numcmp(func_ST_BLOCKS(a),func_ST_BLOCKS(b)); } +inline int cmp_ST_ATIME(mapkey a, mapkey b) { return numcmp(func_ST_ATIME(a),func_ST_ATIME(b)); } +inline int cmp_ST_MTIME(mapkey a, mapkey b) { return numcmp(func_ST_MTIME(a),func_ST_MTIME(b)); } +inline int cmp_ST_CTIME(mapkey a, mapkey b) { return numcmp(func_ST_CTIME(a),func_ST_CTIME(b)); } +inline int cmp_IOCTL_FIBMAP(mapkey a, mapkey b) { return numcmp(func_IOCTL_FIBMAP(a),func_IOCTL_FIBMAP(b)); } // note that this one is backwards -inline const int cmp_FILENAME(mapkey a, mapkey b) { return strcmp(func_FILENAME(b),func_FILENAME(a)); } +inline int cmp_FILENAME(mapkey a, mapkey b) { return strcmp(func_FILENAME(b),func_FILENAME(a)); } #define CMP_NE_RET if(cmp != 0) { DEBUG("%s:(%d)\n","mapcmp-ne-shortcircuit",cmp); DEBUG_STACK_DOWN; return cmp; } int mapcmp(const mapkey *a, const mapkey *b, vector *ofa) { @@ -555,7 +555,7 @@ void process_opts(int argc, char** argv) { // handle the default if(param_fields == NULL) { flag_fields = 1; - param_fields = "stat.st_dev,ioctl.fibmap,stat.st_ino,raw.filename"; + param_fields = (char*)"stat.st_dev,ioctl.fibmap,stat.st_ino,raw.filename"; } process_fieldorder(param_fields); }