From cde886ebdbbac52b02b2ce6815ff6889a77f57da Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 16 Feb 2004 20:09:04 +0000 Subject: [PATCH] const char * additions git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1056 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 34 ++++++++++ bacula/src/baconfig.h | 122 ++++++++++++++++++------------------ bacula/src/lib/bnet.c | 2 +- bacula/src/lib/bsys.c | 4 +- bacula/src/lib/dlist.h | 15 +++-- bacula/src/lib/mem_pool.c | 12 ++-- bacula/src/lib/mem_pool.h | 12 ++-- bacula/src/lib/message.c | 22 +++---- bacula/src/lib/message.h | 6 +- bacula/src/lib/parse_conf.h | 7 ++- bacula/src/lib/protos.h | 14 ++--- bacula/src/lib/smartall.c | 18 +++--- bacula/src/lib/smartall.h | 14 ++--- bacula/src/lib/watchdog.h | 2 +- 14 files changed, 161 insertions(+), 123 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index b7eab57d36..187dd802f5 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -1166,6 +1166,40 @@ Done: (see kernsdone for more) slot number as the destination.AB ==== +==== +SCSI info: +FreeBSD +undef# camcontrol devlist + at scbus0 target 2 lun 0 (pass0,sa0) + at scbus0 target 4 lun 0 (pass1,sa1) + at scbus0 target 4 lun 1 (pass2) + +tapeinfo -f /dev/sg0 with a bad tape in drive 1: +[kern@rufus mtx-1.2.17kes]$ ./tapeinfo -f /dev/sg0 +Product Type: Tape Drive +Vendor ID: 'HP ' +Product ID: 'C5713A ' +Revision: 'H107' +Attached Changer: No +TapeAlert[3]: Hard Error: Uncorrectable read/write error. +TapeAlert[20]: Clean Now: The tape drive neads cleaning NOW. +MinBlock:1 +MaxBlock:16777215 +SCSI ID: 5 +SCSI LUN: 0 +Ready: yes +BufferedMode: yes +Medium Type: Not Loaded +Density Code: 0x26 +BlockSize: 0 +DataCompEnabled: yes +DataCompCapable: yes +DataDeCompEnabled: yes +CompType: 0x20 +DeCompType: 0x0 +Block Position: 0 +===== + ==== Handling removable disks diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index 23931a3127..eebeea0dc4 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -30,8 +30,8 @@ /* Bacula common configuration defines */ -#undef TRUE -#undef FALSE +#undef TRUE +#undef FALSE #define TRUE 1 #define FALSE 0 @@ -40,9 +40,9 @@ #endif #ifdef PROTOTYPES -# define __PROTO(p) p +# define __PROTO(p) p #else -# define __PROTO(p) () +# define __PROTO(p) () #endif #ifdef DEBUG @@ -100,7 +100,7 @@ #define DEFAULT_NETWORK_BUFFER_SIZE (32 * 1024) /* - * Stream definitions. Once defined these must NEVER + * Stream definitions. Once defined these must NEVER * change as they go on the storage media. * Note, the following streams are passed from the SD to the DIR * so that they may be put into the catalog (actually only the @@ -111,55 +111,55 @@ * STREAM_MD5_SIGNATURE * STREAM_SHA1_SIGNATURE */ -#define STREAM_UNIX_ATTRIBUTES 1 /* Generic Unix attributes */ -#define STREAM_FILE_DATA 2 /* Standard uncompressed data */ -#define STREAM_MD5_SIGNATURE 3 /* MD5 signature for the file */ -#define STREAM_GZIP_DATA 4 /* GZip compressed file data */ +#define STREAM_UNIX_ATTRIBUTES 1 /* Generic Unix attributes */ +#define STREAM_FILE_DATA 2 /* Standard uncompressed data */ +#define STREAM_MD5_SIGNATURE 3 /* MD5 signature for the file */ +#define STREAM_GZIP_DATA 4 /* GZip compressed file data */ /* Extended Unix attributes with Win32 Extended data. Deprecated. */ #define STREAM_UNIX_ATTRIBUTES_EX 5 /* Extended Unix attr for Win32 EX */ -#define STREAM_SPARSE_DATA 6 /* Sparse data stream */ +#define STREAM_SPARSE_DATA 6 /* Sparse data stream */ #define STREAM_SPARSE_GZIP_DATA 7 -#define STREAM_PROGRAM_NAMES 8 /* program names for program data */ -#define STREAM_PROGRAM_DATA 9 /* Data needing program */ -#define STREAM_SHA1_SIGNATURE 10 /* SHA1 signature for the file */ -#define STREAM_WIN32_DATA 11 /* Win32 BackupRead data */ -#define STREAM_WIN32_GZIP_DATA 12 /* Gzipped Win32 BackupRead data */ +#define STREAM_PROGRAM_NAMES 8 /* program names for program data */ +#define STREAM_PROGRAM_DATA 9 /* Data needing program */ +#define STREAM_SHA1_SIGNATURE 10 /* SHA1 signature for the file */ +#define STREAM_WIN32_DATA 11 /* Win32 BackupRead data */ +#define STREAM_WIN32_GZIP_DATA 12 /* Gzipped Win32 BackupRead data */ /* - * File type (Bacula defined). + * File type (Bacula defined). * NOTE!!! These are saved in the Attributes record on the tape, so - * do not change them. If need be, add to them. + * do not change them. If need be, add to them. * * This is stored as 32 bits on tape, but only FT_MASK bits are * used for the file type. The upper bits are used to indicate * additional optional fields in the attribute record. */ -#define FT_MASK 0xFFFF /* Bits used by FT (type) */ -#define FT_LNKSAVED 1 /* hard link to file already saved */ -#define FT_REGE 2 /* Regular file but empty */ -#define FT_REG 3 /* Regular file */ -#define FT_LNK 4 /* Soft Link */ -#define FT_DIR 5 /* Directory */ -#define FT_SPEC 6 /* Special file -- chr, blk, fifo, sock */ -#define FT_NOACCESS 7 /* Not able to access */ -#define FT_NOFOLLOW 8 /* Could not follow link */ -#define FT_NOSTAT 9 /* Could not stat file */ -#define FT_NOCHG 10 /* Incremental option, file not changed */ -#define FT_DIRNOCHG 11 /* Incremental option, directory not changed */ -#define FT_ISARCH 12 /* Trying to save archive file */ -#define FT_NORECURSE 13 /* No recursion into directory */ -#define FT_NOFSCHG 14 /* Different file system, prohibited */ -#define FT_NOOPEN 15 /* Could not open directory */ -#define FT_RAW 16 /* Raw block device */ -#define FT_FIFO 17 /* Raw fifo device */ +#define FT_MASK 0xFFFF /* Bits used by FT (type) */ +#define FT_LNKSAVED 1 /* hard link to file already saved */ +#define FT_REGE 2 /* Regular file but empty */ +#define FT_REG 3 /* Regular file */ +#define FT_LNK 4 /* Soft Link */ +#define FT_DIR 5 /* Directory */ +#define FT_SPEC 6 /* Special file -- chr, blk, fifo, sock */ +#define FT_NOACCESS 7 /* Not able to access */ +#define FT_NOFOLLOW 8 /* Could not follow link */ +#define FT_NOSTAT 9 /* Could not stat file */ +#define FT_NOCHG 10 /* Incremental option, file not changed */ +#define FT_DIRNOCHG 11 /* Incremental option, directory not changed */ +#define FT_ISARCH 12 /* Trying to save archive file */ +#define FT_NORECURSE 13 /* No recursion into directory */ +#define FT_NOFSCHG 14 /* Different file system, prohibited */ +#define FT_NOOPEN 15 /* Could not open directory */ +#define FT_RAW 16 /* Raw block device */ +#define FT_FIFO 17 /* Raw fifo device */ /* Definitions for upper part of type word (see above). */ -#define AR_DATA_STREAM (1<<16) /* Data stream id present */ +#define AR_DATA_STREAM (1<<16) /* Data stream id present */ /* * Internal code for Signature types */ -#define NO_SIG 0 +#define NO_SIG 0 #define MD5_SIG 1 #define SHA1_SIG 2 @@ -268,8 +268,8 @@ extern void _v(char *file, int line, pthread_mutex_t *m); */ /* Debug Messages that are printed */ #ifdef DEBUG -#define Dmsg0(lvl, msg) d_msg(__FILE__, __LINE__, lvl, msg) -#define Dmsg1(lvl, msg, a1) d_msg(__FILE__, __LINE__, lvl, msg, a1) +#define Dmsg0(lvl, msg) d_msg(__FILE__, __LINE__, lvl, msg) +#define Dmsg1(lvl, msg, a1) d_msg(__FILE__, __LINE__, lvl, msg, a1) #define Dmsg2(lvl, msg, a1, a2) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2) #define Dmsg3(lvl, msg, a1, a2, a3) d_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3) #define Dmsg4(lvl, msg, arg1, arg2, arg3, arg4) d_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4) @@ -298,8 +298,8 @@ extern void _v(char *file, int line, pthread_mutex_t *m); #endif /* DEBUG */ #ifdef TRACE_FILE -#define Tmsg0(lvl, msg) t_msg(__FILE__, __LINE__, lvl, msg) -#define Tmsg1(lvl, msg, a1) t_msg(__FILE__, __LINE__, lvl, msg, a1) +#define Tmsg0(lvl, msg) t_msg(__FILE__, __LINE__, lvl, msg) +#define Tmsg1(lvl, msg, a1) t_msg(__FILE__, __LINE__, lvl, msg, a1) #define Tmsg2(lvl, msg, a1, a2) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2) #define Tmsg3(lvl, msg, a1, a2, a3) t_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3) #define Tmsg4(lvl, msg, arg1, arg2, arg3, arg4) t_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4) @@ -330,8 +330,8 @@ extern void _v(char *file, int line, pthread_mutex_t *m); /* Messages that are printed (uses d_msg) */ -#define Pmsg0(lvl, msg) p_msg(__FILE__, __LINE__, lvl, msg) -#define Pmsg1(lvl, msg, a1) p_msg(__FILE__, __LINE__, lvl, msg, a1) +#define Pmsg0(lvl, msg) p_msg(__FILE__, __LINE__, lvl, msg) +#define Pmsg1(lvl, msg, a1) p_msg(__FILE__, __LINE__, lvl, msg, a1) #define Pmsg2(lvl, msg, a1, a2) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2) #define Pmsg3(lvl, msg, a1, a2, a3) p_msg(__FILE__, __LINE__, lvl, msg, a1, a2, a3) #define Pmsg4(lvl, msg, arg1, arg2, arg3, arg4) p_msg(__FILE__, __LINE__, lvl, msg, arg1, arg2, arg3, arg4) @@ -348,17 +348,17 @@ extern void _v(char *file, int line, pthread_mutex_t *m); /* Daemon Error Messages that are delivered according to the message resource */ -#define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg) -#define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1) -#define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2) +#define Emsg0(typ, lvl, msg) e_msg(__FILE__, __LINE__, typ, lvl, msg) +#define Emsg1(typ, lvl, msg, a1) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1) +#define Emsg2(typ, lvl, msg, a1, a2) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2) #define Emsg3(typ, lvl, msg, a1, a2, a3) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3) #define Emsg4(typ, lvl, msg, a1, a2, a3, a4) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4) #define Emsg5(typ, lvl, msg, a1, a2, a3, a4, a5) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5) #define Emsg6(typ, lvl, msg, a1, a2, a3, a4, a5, a6) e_msg(__FILE__, __LINE__, typ, lvl, msg, a1, a2, a3, a4, a5, a6) /* Job Error Messages that are delivered according to the message resource */ -#define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg) -#define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1) +#define Jmsg0(jcr, typ, lvl, msg) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg) +#define Jmsg1(jcr, typ, lvl, msg, a1) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1) #define Jmsg2(jcr, typ, lvl, msg, a1, a2) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2) #define Jmsg3(jcr, typ, lvl, msg, a1, a2, a3) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3) #define Jmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4) @@ -366,8 +366,8 @@ extern void _v(char *file, int line, pthread_mutex_t *m); #define Jmsg6(jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6) j_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4, a5, a6) /* Queued Job Error Messages that are delivered according to the message resource */ -#define Qmsg0(jcr, typ, lvl, msg) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg) -#define Qmsg1(jcr, typ, lvl, msg, a1) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1) +#define Qmsg0(jcr, typ, lvl, msg) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg) +#define Qmsg1(jcr, typ, lvl, msg, a1) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1) #define Qmsg2(jcr, typ, lvl, msg, a1, a2) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2) #define Qmsg3(jcr, typ, lvl, msg, a1, a2, a3) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3) #define Qmsg4(jcr, typ, lvl, msg, a1, a2, a3, a4) q_msg(__FILE__, __LINE__, jcr, typ, lvl, msg, a1, a2, a3, a4) @@ -376,8 +376,8 @@ extern void _v(char *file, int line, pthread_mutex_t *m); /* Memory Messages that are edited into a Pool Memory buffer */ -#define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg) -#define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1) +#define Mmsg0(buf, msg) m_msg(__FILE__, __LINE__, buf, msg) +#define Mmsg1(buf, msg, a1) m_msg(__FILE__, __LINE__, buf, msg, a1) #define Mmsg2(buf, msg, a1, a2) m_msg(__FILE__, __LINE__, buf, msg, a1, a2) #define Mmsg3(buf, msg, a1, a2, a3) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3) #define Mmsg4(buf, msg, a1, a2, a3, a4) m_msg(__FILE__, __LINE__, buf, msg, a1, a2, a3, a4) @@ -389,16 +389,16 @@ extern void _v(char *file, int line, pthread_mutex_t *m); #define Mmsg15(buf,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) m_msg(__FILE__,__LINE__,buf,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) /* Edit message into Pool Memory buffer -- no __FILE__ and __LINE__ */ -int Mmsg(POOLMEM **msgbuf, char *fmt,...); +int Mmsg(POOLMEM **msgbuf, const char *fmt,...); struct JCR; -void d_msg(char *file, int line, int level, char *fmt,...); -void p_msg(char *file, int line, int level, char *fmt,...); -void e_msg(char *file, int line, int type, int level, char *fmt,...); -void j_msg(char *file, int line, JCR *jcr, int type, int level, char *fmt,...); -void q_msg(char *file, int line, JCR *jcr, int type, int level, char *fmt,...); -int m_msg(char *file, int line, POOLMEM **msgbuf, char *fmt,...); +void d_msg(const char *file, int line, int level, const char *fmt,...); +void p_msg(const char *file, int line, int level, const char *fmt,...); +void e_msg(const char *file, int line, int type, int level, const char *fmt,...); +void j_msg(const char *file, int line, JCR *jcr, int type, int level, const char *fmt,...); +void q_msg(const char *file, int line, JCR *jcr, int type, int level, const char *fmt,...); +int m_msg(const char *file, int line, POOLMEM **msgbuf, const char *fmt,...); /* Use our strdup with smartalloc */ @@ -410,9 +410,9 @@ int m_msg(char *file, int line, POOLMEM **msgbuf, char *fmt,...); #define fgets(x,y,z) bfgets((x), (y), (z)) #ifdef DEBUG -#define bstrdup(str) strcpy((char *) b_malloc(__FILE__,__LINE__,strlen((str))+1),(str)) +#define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str)) #else -#define bstrdup(str) strcpy((char *) bmalloc(strlen((str))+1),(str)) +#define bstrdup(str) strcpy((char *)bmalloc(strlen((str))+1),(str)) #endif #ifdef DEBUG diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index 6a4a15c0b1..f936cc4dc5 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -682,7 +682,7 @@ char *bnet_strerror(BSOCK *bsock) * 1 on success */ int -bnet_fsend(BSOCK *bs, char *fmt, ...) +bnet_fsend(BSOCK *bs, const char *fmt, ...) { va_list arg_ptr; int maxlen; diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index d129747b89..57a7c02ab0 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -66,7 +66,7 @@ void *bmalloc(size_t size) } #endif -void *b_malloc(char *file, int line, size_t size) +void *b_malloc(const char *file, int line, size_t size) { void *buf; @@ -108,7 +108,7 @@ void *bcalloc (size_t size1, size_t size2) /* * Implement snprintf */ -int bsnprintf(char *str, int32_t size, const char *fmt, ...) +int bsnprintf(char *str, int32_t size, const char *fmt, ...) { #ifdef HAVE_VSNPRINTF va_list arg_ptr; diff --git a/bacula/src/lib/dlist.h b/bacula/src/lib/dlist.h index e607b776cb..cef7d3016c 100644 --- a/bacula/src/lib/dlist.h +++ b/bacula/src/lib/dlist.h @@ -30,14 +30,17 @@ /* In case you want to specifically specify the offset to the link */ #define OFFSET(item, link) ((char *)(link) - (char *)(item)) -#ifdef HAVE_WIN32 -/* Extra ***& workaround for VisualC Studio */ -#define foreach_dlist(var, list) \ - for((var)=NULL; (*((void **)&(var))=(void*)((list)->next(var))); ) -#else -/* +/* + * There is a lot of extra casting here to work around the fact + * that some compilers (Sun and Visual C++) do not accept + * (void *) as an lvalue on the left side of an equal. + * * Loop var through each member of list */ +#define foreach_dlist(var, list) \ + for((var)=NULL; (*((void **)&(var))=(void*)((list)->next(var))); ) + +#ifdef the_old_way #define foreach_dlist(var, list) \ for((var)=NULL; (((void *)(var))=(list)->next(var)); ) #endif diff --git a/bacula/src/lib/mem_pool.c b/bacula/src/lib/mem_pool.c index 74fb59bf73..55240b1512 100644 --- a/bacula/src/lib/mem_pool.c +++ b/bacula/src/lib/mem_pool.c @@ -92,7 +92,7 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; #define HEAD_SIZE BALIGN(sizeof(struct abufhead)) -POOLMEM *sm_get_pool_memory(char *fname, int lineno, int pool) +POOLMEM *sm_get_pool_memory(const char *fname, int lineno, int pool) { struct abufhead *buf; @@ -129,7 +129,7 @@ POOLMEM *sm_get_pool_memory(char *fname, int lineno, int pool) } /* Get nonpool memory of size requested */ -POOLMEM *sm_get_memory(char *fname, int lineno, int32_t size) +POOLMEM *sm_get_memory(const char *fname, int lineno, int32_t size) { struct abufhead *buf; int pool = 0; @@ -148,7 +148,7 @@ POOLMEM *sm_get_memory(char *fname, int lineno, int32_t size) /* Return the size of a memory buffer */ -int32_t sm_sizeof_pool_memory(char *fname, int lineno, POOLMEM *obuf) +int32_t sm_sizeof_pool_memory(const char *fname, int lineno, POOLMEM *obuf) { char *cp = (char *)obuf; @@ -158,7 +158,7 @@ int32_t sm_sizeof_pool_memory(char *fname, int lineno, POOLMEM *obuf) } /* Realloc pool memory buffer */ -POOLMEM *sm_realloc_pool_memory(char *fname, int lineno, POOLMEM *obuf, int32_t size) +POOLMEM *sm_realloc_pool_memory(const char *fname, int lineno, POOLMEM *obuf, int32_t size) { char *cp = (char *)obuf; void *buf; @@ -181,7 +181,7 @@ POOLMEM *sm_realloc_pool_memory(char *fname, int lineno, POOLMEM *obuf, int32_t return (POOLMEM *)(((char *)buf)+HEAD_SIZE); } -POOLMEM *sm_check_pool_memory_size(char *fname, int lineno, POOLMEM *obuf, int32_t size) +POOLMEM *sm_check_pool_memory_size(const char *fname, int lineno, POOLMEM *obuf, int32_t size) { ASSERT(obuf); if (size <= sizeof_pool_memory(obuf)) { @@ -191,7 +191,7 @@ POOLMEM *sm_check_pool_memory_size(char *fname, int lineno, POOLMEM *obuf, int32 } /* Free a memory buffer */ -void sm_free_pool_memory(char *fname, int lineno, POOLMEM *obuf) +void sm_free_pool_memory(const char *fname, int lineno, POOLMEM *obuf) { struct abufhead *buf; int pool; diff --git a/bacula/src/lib/mem_pool.h b/bacula/src/lib/mem_pool.h index 96fa5a7de8..839effc8ef 100644 --- a/bacula/src/lib/mem_pool.h +++ b/bacula/src/lib/mem_pool.h @@ -32,23 +32,23 @@ #ifdef SMARTALLOC #define get_pool_memory(pool) sm_get_pool_memory(__FILE__, __LINE__, pool) -extern POOLMEM *sm_get_pool_memory(char *file, int line, int pool); +extern POOLMEM *sm_get_pool_memory(const char *file, int line, int pool); #define get_memory(size) sm_get_memory(__FILE__, __LINE__, size) -extern POOLMEM *sm_get_memory(char *fname, int line, int32_t size); +extern POOLMEM *sm_get_memory(const char *fname, int line, int32_t size); #define sizeof_pool_memory(buf) sm_sizeof_pool_memory(__FILE__, __LINE__, buf) -extern int32_t sm_sizeof_pool_memory(char *fname, int line, POOLMEM *buf); +extern int32_t sm_sizeof_pool_memory(const char *fname, int line, POOLMEM *buf); #define realloc_pool_memory(buf,size) sm_realloc_pool_memory(__FILE__, __LINE__, buf, size) -extern POOLMEM *sm_realloc_pool_memory(char *fname, int line, POOLMEM *buf, int32_t size); +extern POOLMEM *sm_realloc_pool_memory(const char *fname, int line, POOLMEM *buf, int32_t size); #define check_pool_memory_size(buf,size) sm_check_pool_memory_size(__FILE__, __LINE__, buf, size) -extern POOLMEM *sm_check_pool_memory_size(char *fname, int line, POOLMEM *buf, int32_t size); +extern POOLMEM *sm_check_pool_memory_size(const char *fname, int line, POOLMEM *buf, int32_t size); #define free_pool_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x) #define free_memory(x) sm_free_pool_memory(__FILE__, __LINE__, x) -extern void sm_free_pool_memory(char *fname, int line, POOLMEM *buf); +extern void sm_free_pool_memory(const char *fname, int line, POOLMEM *buf); #else diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index bae1f30b2b..03aab84941 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -89,7 +89,7 @@ static MSGS *daemon_msgs; /* global messages */ * argv is NULL to avoid doing the path code twice. */ #define BTRACE_EXTRA 20 -void my_name_is(int argc, char *argv[], char *name) +void my_name_is(int argc, char *argv[], const char *name) { char *l, *p, *q; char cpath[400], npath[400]; @@ -730,7 +730,7 @@ void dispatch_message(JCR *jcr, int type, int level, char *msg) * are not printed. */ void -d_msg(char *file, int line, int level, char *fmt,...) +d_msg(const char *file, int line, int level, const char *fmt,...) { char buf[5000]; int len; @@ -790,7 +790,7 @@ d_msg(char *file, int line, int level, char *fmt,...) * are not printed. */ void -p_msg(char *file, int line, int level, char *fmt,...) +p_msg(const char *file, int line, int level, const char *fmt,...) { char buf[5000]; int len; @@ -823,7 +823,7 @@ p_msg(char *file, int line, int level, char *fmt,...) * are not printed. */ void -t_msg(char *file, int line, int level, char *fmt,...) +t_msg(const char *file, int line, int level, const char *fmt,...) { char buf[5000]; int len; @@ -868,7 +868,7 @@ t_msg(char *file, int line, int level, char *fmt,...) * */ void -e_msg(char *file, int line, int type, int level, char *fmt,...) +e_msg(const char *file, int line, int type, int level, const char *fmt,...) { char buf[5000]; va_list arg_ptr; @@ -935,7 +935,7 @@ e_msg(char *file, int line, int type, int level, char *fmt,...) * */ void -Jmsg(JCR *jcr, int type, int level, char *fmt,...) +Jmsg(JCR *jcr, int type, int level, const char *fmt,...) { char rbuf[5000]; va_list arg_ptr; @@ -1030,7 +1030,7 @@ Jmsg(JCR *jcr, int type, int level, char *fmt,...) * If we come here, prefix the message with the file:line-number, * then pass it on to the normal Jmsg routine. */ -void j_msg(char *file, int line, JCR *jcr, int type, int level, char *fmt,...) +void j_msg(const char *file, int line, JCR *jcr, int type, int level, const char *fmt,...) { va_list arg_ptr; int i, len, maxlen; @@ -1057,7 +1057,7 @@ again: /* * Edit a message into a Pool memory buffer, with file:lineno */ -int m_msg(char *file, int line, POOLMEM **pool_buf, char *fmt, ...) +int m_msg(const char *file, int line, POOLMEM **pool_buf, const char *fmt, ...) { va_list arg_ptr; int i, len, maxlen; @@ -1080,7 +1080,7 @@ again: * Edit a message into a Pool Memory buffer NO file:lineno * Returns: string length of what was edited. */ -int Mmsg(POOLMEM **pool_buf, char *fmt, ...) +int Mmsg(POOLMEM **pool_buf, const char *fmt, ...) { va_list arg_ptr; int len, maxlen; @@ -1104,7 +1104,7 @@ static pthread_mutex_t msg_queue_mutex = PTHREAD_MUTEX_INITIALIZER; * is generally used in low level routines (msg handler, bnet) * to prevent recursion. */ -void Qmsg(JCR *jcr, int type, int level, char *fmt,...) +void Qmsg(JCR *jcr, int type, int level, const char *fmt,...) { va_list arg_ptr; int len, maxlen; @@ -1156,7 +1156,7 @@ void dequeue_messages(JCR *jcr) * If we come here, prefix the message with the file:line-number, * then pass it on to the normal Qmsg routine. */ -void q_msg(char *file, int line, JCR *jcr, int type, int level, char *fmt,...) +void q_msg(const char *file, int line, JCR *jcr, int type, int level, const char *fmt,...) { va_list arg_ptr; int i, len, maxlen; diff --git a/bacula/src/lib/message.h b/bacula/src/lib/message.h index 92f822e364..f891802341 100644 --- a/bacula/src/lib/message.h +++ b/bacula/src/lib/message.h @@ -120,9 +120,9 @@ struct MQUEUE_ITEM { }; -void d_msg(char *file, int line, int level, char *fmt,...); -void e_msg(char *file, int line, int type, int level, char *fmt,...); -void Jmsg(JCR *jcr, int type, int level, char *fmt,...); +void d_msg(const char *file, int line, int level, const char *fmt,...); +void e_msg(const char *file, int line, int type, int level, const char *fmt,...); +void Jmsg(JCR *jcr, int type, int level, const char *fmt,...); extern int debug_level; extern int verbose; diff --git a/bacula/src/lib/parse_conf.h b/bacula/src/lib/parse_conf.h index 7a406faabf..78c1beba24 100644 --- a/bacula/src/lib/parse_conf.h +++ b/bacula/src/lib/parse_conf.h @@ -110,11 +110,12 @@ void free_resource(int type); void init_resource(int type, struct res_items *item); void save_resource(int type, struct res_items *item, int pass); char *res_to_str(int rcode); + /* Loop through each resource of type, returning in var */ -#ifdef HAVE_WIN32 #define foreach_res(var, type) \ - for(var=NULL; *((void **)&(var))=(void *)GetNextRes((type), (RES *)var);) -#else + for(var=NULL; (*((void **)&(var))=(void *)GetNextRes((type), (RES *)var));) + +#ifdef the_old_way #define foreach_res(var, type) \ for((var)=NULL; (((void *)(var))=GetNextRes((type), (RES *)var));) #endif diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 54bcb445a2..63cb677fc7 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -41,15 +41,15 @@ int bin_to_base64 (char *buf, char *bin, int len); /* bsys.c */ char *bstrncpy (char *dest, const char *src, int maxlen); char *bstrncat (char *dest, const char *src, int maxlen); -void *b_malloc (char *file, int line, size_t size); +void *b_malloc (const char *file, int line, size_t size); #ifndef DEBUG void *bmalloc (size_t size); #endif void *brealloc (void *buf, size_t size); void *bcalloc (size_t size1, size_t size2); -int bsnprintf (char *str, int32_t size, const char *format, ...); -int bvsnprintf (char *str, int32_t size, const char *format, va_list ap); -int pool_sprintf (char *pool_buf, char *fmt, ...); +int bsnprintf (char *str, int32_t size, const char *format, ...); +int bvsnprintf (char *str, int32_t size, const char *format, va_list ap); +int pool_sprintf (char *pool_buf, const char *fmt, ...); void create_pid_file (char *dir, char *progname, int port); int delete_pid_file (char *dir, char *progname, int port); void drop (char *uid, char *gid); @@ -63,7 +63,7 @@ long long int strtoll (const char *ptr, char **endptr, int base); /* bnet.c */ int32_t bnet_recv (BSOCK *bsock); int bnet_send (BSOCK *bsock); -int bnet_fsend (BSOCK *bs, char *fmt, ...); +int bnet_fsend (BSOCK *bs, const char *fmt, ...); int bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw); int bnet_sig (BSOCK *bs, int sig); int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has); @@ -135,13 +135,13 @@ char * lex_tok_to_str (int token); int lex_get_token (LEX *lf, int expect); /* message.c */ -void my_name_is (int argc, char *argv[], char *name); +void my_name_is (int argc, char *argv[], const char *name); void init_msg (JCR *jcr, MSGS *msg); void term_msg (void); void close_msg (JCR *jcr); void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code); void rem_msg_dest (MSGS *msg, int dest, int type, char *where); -void Jmsg (JCR *jcr, int type, int level, char *fmt, ...); +void Jmsg (JCR *jcr, int type, int level, const char *fmt, ...); void dispatch_message (JCR *jcr, int type, int level, char *buf); void init_console_msg (char *wd); void free_msgs_res (MSGS *msgs); diff --git a/bacula/src/lib/smartall.c b/bacula/src/lib/smartall.c index 5950cf794d..3a5a679ee7 100644 --- a/bacula/src/lib/smartall.c +++ b/bacula/src/lib/smartall.c @@ -65,7 +65,7 @@ typedef unsigned short sm_ushort; struct abufhead { struct b_queue abq; /* Links on allocated queue */ unsigned ablen; /* Buffer length in bytes */ - char *abfname; /* File name pointer */ + const char *abfname; /* File name pointer */ sm_ushort ablineno; /* Line number of allocation */ }; @@ -81,7 +81,7 @@ static Boolean bufimode = False; /* Buffers not tracked when True */ /* SMALLOC -- Allocate buffer, enqueing on the orphaned buffer tracking list. */ -static void *smalloc(char *fname, int lineno, unsigned int nbytes) +static void *smalloc(const char *fname, int lineno, unsigned int nbytes) { char *buf; @@ -117,7 +117,7 @@ static void *smalloc(char *fname, int lineno, unsigned int nbytes) /* SM_NEW_OWNER -- Update the File and line number for a buffer This is to accomodate mem_pool. */ -void sm_new_owner(char *fname, int lineno, char *buf) +void sm_new_owner(const char *fname, int lineno, char *buf) { buf -= HEAD_SIZE; /* Decrement to header */ ((struct abufhead *)buf)->abfname = bufimode ? NULL : fname; @@ -130,7 +130,7 @@ void sm_new_owner(char *fname, int lineno, char *buf) free(x) is defined to generate a call to this routine. */ -void sm_free(char *file, int line, void *fp) +void sm_free(const char *file, int line, void *fp) { char *cp = (char *) fp; struct b_queue *qp; @@ -186,7 +186,7 @@ void sm_free(char *file, int line, void *fp) /* SM_MALLOC -- Allocate buffer. NULL is returned if no memory was available. */ -void *sm_malloc(char *fname, int lineno, unsigned int nbytes) +void *sm_malloc(const char *fname, int lineno, unsigned int nbytes) { void *buf; @@ -205,7 +205,7 @@ void *sm_malloc(char *fname, int lineno, unsigned int nbytes) /* SM_CALLOC -- Allocate an array and clear it to zero. */ -void *sm_calloc(char *fname, int lineno, +void *sm_calloc(const char *fname, int lineno, unsigned int nelem, unsigned int elsize) { void *buf; @@ -227,7 +227,7 @@ void *sm_calloc(char *fname, int lineno, This may result in programs which make heavy use of realloc() running much slower than normally. */ -void *sm_realloc(char *fname, int lineno, void *ptr, unsigned int size) +void *sm_realloc(const char *fname, int lineno, void *ptr, unsigned int size) { unsigned osize; void *buf; @@ -378,7 +378,7 @@ void sm_dump(Boolean bufdump) #undef sm_check /* SM_CHECK -- Check the buffers and dump if any damage exists. */ -void sm_check(char *fname, int lineno, Boolean bufdump) +void sm_check(const char *fname, int lineno, Boolean bufdump) { if (!sm_check_rtn(fname, lineno, bufdump)) { Emsg2(M_ABORT, 0, "Damaged buffer found. Called from %s:%d\n", @@ -388,7 +388,7 @@ void sm_check(char *fname, int lineno, Boolean bufdump) #undef sm_check_rtn /* SM_CHECK_RTN -- Check the buffers and return 1 if OK otherwise 0 */ -int sm_check_rtn(char *fname, int lineno, Boolean bufdump) +int sm_check_rtn(const char *fname, int lineno, Boolean bufdump) { struct abufhead *ap; int bad, badbuf = 0; diff --git a/bacula/src/lib/smartall.h b/bacula/src/lib/smartall.h index 5405aa2e5c..ad72bcedd6 100644 --- a/bacula/src/lib/smartall.h +++ b/bacula/src/lib/smartall.h @@ -31,21 +31,21 @@ typedef enum {False = 0, True = 1} Boolean; -extern void *sm_malloc(char *fname, int lineno, unsigned int nbytes), - *sm_calloc(char *fname, int lineno, +extern void *sm_malloc(const char *fname, int lineno, unsigned int nbytes), + *sm_calloc(const char *fname, int lineno, unsigned int nelem, unsigned int elsize), - *sm_realloc(char *fname, int lineno, void *ptr, unsigned int size), + *sm_realloc(const char *fname, int lineno, void *ptr, unsigned int size), *actuallymalloc(unsigned int size), *actuallycalloc(unsigned int nelem, unsigned int elsize), *actuallyrealloc(void *ptr, unsigned int size); -extern void sm_free(char *fname, int lineno, void *fp); +extern void sm_free(const char *fname, int lineno, void *fp); extern void actuallyfree(void *cp), sm_dump(Boolean bufdump), sm_static(int mode); -extern void sm_new_owner(char *fname, int lineno, char *buf); +extern void sm_new_owner(const char *fname, int lineno, char *buf); #ifdef SMCHECK -extern void sm_check(char *fname, int lineno, Boolean bufdump); -extern int sm_check_rtn(char *fname, int lineno, Boolean bufdump); +extern void sm_check(const char *fname, int lineno, Boolean bufdump); +extern int sm_check_rtn(const char *fname, int lineno, Boolean bufdump); #else #define sm_check(f, l, fl) #define sm_check_rtn(f, l, fl) 1 diff --git a/bacula/src/lib/watchdog.h b/bacula/src/lib/watchdog.h index 8d51d2455c..04725cf018 100644 --- a/bacula/src/lib/watchdog.h +++ b/bacula/src/lib/watchdog.h @@ -27,7 +27,7 @@ enum { TYPE_CHILD = 1, TYPE_PTHREAD, - TYPE_BSOCK, + TYPE_BSOCK }; #define TIMEOUT_SIGNAL SIGUSR2 -- 2.39.2