Browse Source

* samba/*: Added many const qualifiers to properly fix the
warnings emitted by gcc with -Wwrite-strings.
* smbfs.c: Likewise.

Roland Illig 19 years ago
parent
commit
5ddb6be28e

+ 6 - 0
vfs/ChangeLog

@@ -1,3 +1,9 @@
+2005-09-07  Roland Illig  <roland.illig@gmx.de>
+
+	* samba/*: Added many const qualifiers to properly fix the
+	warnings emitted by gcc with -Wwrite-strings.
+	* smbfs.c: Likewise.
+
 2005-09-05  Roland Illig  <roland.illig@gmx.de>
 
 	* direntry.c: Added const qualifiers to work around gcc

+ 22 - 22
vfs/samba/include/proto.h

@@ -6,13 +6,13 @@
 
 char *unix2dos_format(char *str,BOOL overwrite);
 char *dos2unix_format(char *str, BOOL overwrite);
-void interpret_character_set(char *str);
+void interpret_character_set(const char *str);
 
 /* The following definitions come from lib/charset.c  */
 
 void charset_initialise(void);
 void codepage_initialise(int client_codepage);
-void add_char_string(char *s);
+void add_char_string(const char *s);
 
 /* The following definitions come from lib/debug.c  */
 
@@ -36,7 +36,7 @@ struct in_addr *iface_ip(struct in_addr ip);
 
 /* The following definitions come from lib/kanji.c  */
 
-void interpret_coding_system(char *str);
+void interpret_coding_system(const char *str);
 BOOL is_multibyte_codepage(void);
 void initialize_multibyte_vectors( int client_codepage);
 
@@ -91,14 +91,14 @@ time_t get_create_time(SMB_STRUCT_STAT *st,BOOL fake_dirs);
 
 /* The following definitions come from lib/username.c  */
 
-char *get_home_dir(char *user);
-BOOL map_username(char *user);
-struct passwd *Get_Pwnam(char *user,BOOL allow_change);
-BOOL user_in_list(char *user,char *list);
+const char *get_home_dir(char *user);
+BOOL map_username(const char *user);
+struct passwd *Get_Pwnam(const char *user);
+BOOL user_in_list(const char *user,char *list);
 
 /* The following definitions come from lib/util.c  */
 
-char *tmpdir(void);
+const char *tmpdir(void);
 BOOL in_group(gid_t group, gid_t current_gid, int ngroups, gid_t *groups);
 char *Atoic(char *p, int *n, char *c);
 char *get_numlist(char *p, uint32 **num, int *count);
@@ -139,8 +139,8 @@ void *Realloc(void *p,size_t size);
 BOOL get_myname(char *my_name,struct in_addr *ip);
 BOOL ip_equal(struct in_addr ip1,struct in_addr ip2);
 int interpret_protocol(char *str,int def);
-uint32 interpret_addr(char *str);
-struct in_addr *interpret_addr2(char *str);
+uint32 interpret_addr(const char *str);
+struct in_addr *interpret_addr2(const char *str);
 BOOL zero_ip(struct in_addr ip);
 BOOL matchname(char *remotehost,struct in_addr  addr);
 void standard_sub_basic(char *str);
@@ -150,7 +150,7 @@ struct hostent *Get_Hostbyname(const char *name);
 char *uidtoname(uid_t uid);
 char *gidtoname(gid_t gid);
 uid_t nametouid(const char *name);
-void smb_panic(char *why);
+void smb_panic(const char *why);
 char *readdirname(DIR *p);
 BOOL is_in_path(char *name, name_compare_entry *namelist);
 void set_namearray(name_compare_entry **ppname_array, char *namelist);
@@ -207,7 +207,7 @@ char *client_addr(int fd);
 /* The following definitions come from lib/util_str.c  */
 
 void set_first_token(char *ptr);
-BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize);
+BOOL next_token(char **ptr,char *buff, const char *sep, size_t bufsize);
 char **toktocliplist(int *ctok, char *sep);
 int StrCaseCmp(const char *s, const char *t);
 int StrnCaseCmp(const char *s, const char *t, size_t n);
@@ -265,7 +265,7 @@ BOOL cli_session_setup(struct cli_state *cli,
 		       char *workgroup);
 BOOL cli_ulogoff(struct cli_state *cli);
 BOOL cli_send_tconX(struct cli_state *cli, 
-		    char *share, char *dev, char *pass, int passlen);
+		    const char *share, const char *dev, const char *pass, int passlen);
 BOOL cli_tdis(struct cli_state *cli);
 BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst);
 BOOL cli_unlink(struct cli_state *cli, char *fname);
@@ -279,9 +279,9 @@ BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int
 size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size);
 ssize_t cli_write(struct cli_state *cli,
 		  int fnum, uint16 write_mode,
-		  char *buf, off_t offset, size_t size);
+		  const char *buf, off_t offset, size_t size);
 ssize_t cli_smbwrite(struct cli_state *cli,
-		     int fnum, char *buf, off_t offset, size_t size);
+		     int fnum, const char *buf, off_t offset, size_t size);
 BOOL cli_getattrE(struct cli_state *cli, int fd, 
 		  uint16 *attr, size_t *size, 
 		  time_t *c_time, time_t *a_time, time_t *m_time);
@@ -327,7 +327,7 @@ BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
 
 struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOOL recurse,
          struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *));
-FILE *startlmhosts(char *fname);
+FILE *startlmhosts(const char *fname);
 BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr);
 void endlmhosts(FILE *fp);
 BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type);
@@ -588,12 +588,12 @@ int lp_minprintspace(int );
 int lp_printing(int );
 int lp_oplock_contention_limit(int );
 char lp_magicchar(int );
-BOOL lp_add_home(char *pszHomename, int iDefaultService, char *pszHomedir);
+BOOL lp_add_home(const char *pszHomename, int iDefaultService, const char *pszHomedir);
 int lp_add_service(char *pszService, int iDefaultService);
 BOOL lp_add_printer(char *pszPrintername, int iDefaultService);
 BOOL lp_file_list_changed(void);
 void *lp_local_ptr(int snum, void *ptr);
-BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue);
+BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue);
 BOOL lp_is_default(int snum, struct parm_struct *parm);
 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters);
 BOOL lp_snum_ok(int iService);
@@ -603,7 +603,7 @@ void lp_killunused(BOOL (*snumused)(int ));
 BOOL lp_load(const char *pszFname,BOOL global_only, BOOL save_defaults, BOOL add_ipc);
 void lp_resetnumservices(void);
 int lp_numservices(void);
-int lp_servicenumber(char *pszServiceName);
+int lp_servicenumber(const char *pszServiceName);
 char *volume_label(int snum);
 int lp_default_server_announce(void);
 int lp_major_announce_version(void);
@@ -614,7 +614,7 @@ BOOL lp_kernel_oplocks(void);
 
 /* The following definitions come from param/params.c  */
 
-BOOL pm_process( char *FileName,
-                 BOOL (*sfunc)(char *),
-                 BOOL (*pfunc)(char *, char *) );
+BOOL pm_process( const char *FileName,
+                 BOOL (*sfunc)(const char *),
+                 BOOL (*pfunc)(const char *, const char *) );
 #endif /* _PROTO_H_ */

+ 2 - 2
vfs/samba/include/smb.h

@@ -69,7 +69,7 @@ typedef int BOOL;
    arguemnts to DEBUG() right. We have got them wrong too often in the 
    past */
 #ifdef HAVE_STDARG_H
-int  Debug1( char *, ... )
+int  Debug1( const char *, ... )
 #ifdef __GNUC__
      __attribute__ ((format (printf, 1, 2)))
 #endif
@@ -874,7 +874,7 @@ struct parm_struct
 	parm_type type;
 	parm_class class;
 	void *ptr;
-	BOOL (*special)(char *, char **);
+	BOOL (*special)(const char *, char **);
 	const struct enum_list *enum_list;
 	unsigned flags;
 	union {

+ 1 - 1
vfs/samba/lib/charcnv.c

@@ -216,7 +216,7 @@ char *dos2unix_format(char *str, BOOL overwrite)
 /*
  * Interpret character set.
  */
-void interpret_character_set(char *str)
+void interpret_character_set(const char *str)
 {
     if (strequal (str, "iso8859-1")) {
         init_iso8859_1();

+ 1 - 1
vfs/samba/lib/charset.c

@@ -374,7 +374,7 @@ for code page %d failed. Using default client codepage 850\n",
 /*******************************************************************
 add characters depending on a string passed by the user
 ********************************************************************/
-void add_char_string(char *s)
+void add_char_string(const char *s)
 {
   char *extra_chars = (char *)strdup(s);
   char *t;

+ 4 - 4
vfs/samba/lib/debug.c

@@ -131,13 +131,13 @@ void setup_logging( const char *pname, BOOL interactive )
  * ************************************************************************** **
  */
 #ifdef HAVE_STDARG_H
- int Debug1( char *format_str, ... )
+ int Debug1( const char *format_str, ... )
 {
 #else
  int Debug1(va_alist)
 va_dcl
 {  
-  char *format_str;
+  const char *format_str;
 #endif
   va_list ap;  
   int old_errno = errno;
@@ -148,7 +148,7 @@ va_dcl
     va_start( ap, format_str );
 #else
     va_start( ap );
-    format_str = va_arg( ap, char * );
+    format_str = va_arg( ap, const char * );
 #endif
     (void)vfprintf( dbf, format_str, ap );
     va_end( ap );
@@ -182,7 +182,7 @@ va_dcl
     va_start( ap, format_str );
 #else
     va_start( ap );
-    format_str = va_arg( ap, char * );
+    format_str = va_arg( ap, const char * );
 #endif
     (void)vfprintf( dbf, format_str, ap );
     va_end( ap );

+ 1 - 1
vfs/samba/lib/interface.c

@@ -124,7 +124,7 @@ static void get_broadcast(struct in_addr *if_ipaddr,
 load a list of network interfaces
 ****************************************************************************/
 static void interpret_interfaces(char *s, struct interface **interfaces,
-		char *description)
+		const char *description)
 {
   char *ptr;
   fstring token;

+ 1 - 1
vfs/samba/lib/kanji.c

@@ -1046,7 +1046,7 @@ static void setup_string_function(int codes)
  Interpret coding system.
 ************************************************************************/
 
-void interpret_coding_system(char *str)
+void interpret_coding_system(const char *str)
 {
     int codes = UNKNOWN_CODE;
     

+ 12 - 20
vfs/samba/lib/username.c

@@ -23,17 +23,17 @@
 extern int DEBUGLEVEL;
 
 /* internal functions */
-static struct passwd *uname_string_combinations(char *s, struct passwd * (*fn) (char *), int N);
-static struct passwd *uname_string_combinations2(char *s, int offset, struct passwd * (*fn) (char *), int N);
+static struct passwd *uname_string_combinations(char *s, struct passwd * (*fn) (const char *), int N);
+static struct passwd *uname_string_combinations2(char *s, int offset, struct passwd * (*fn) (const char *), int N);
 
 /****************************************************************************
 get a users home directory.
 ****************************************************************************/
-char *get_home_dir(char *user)
+const char *get_home_dir(char *user)
 {
   struct passwd *pass;
 
-  pass = Get_Pwnam(user, False);
+  pass = Get_Pwnam(user);
 
   if (!pass) return(NULL);
   return(pass->pw_dir);      
@@ -51,7 +51,7 @@ function. Previously, the map_username was being called
 every time Get_Pwnam was called.
 Returns True if username was changed, false otherwise.
 ********************************************************************/
-BOOL map_username(char *user)
+BOOL map_username(const char *user)
 {
   static BOOL initialised=False;
   static fstring last_from,last_to;
@@ -148,7 +148,7 @@ BOOL map_username(char *user)
 /****************************************************************************
 Get_Pwnam wrapper
 ****************************************************************************/
-static struct passwd *_Get_Pwnam(char *s)
+static struct passwd *_Get_Pwnam(const char *s)
 {
   struct passwd *ret;
 
@@ -174,24 +174,19 @@ static struct passwd *_Get_Pwnam(char *s)
 /****************************************************************************
 a wrapper for getpwnam() that tries with all lower and all upper case 
 if the initial name fails. Also tried with first letter capitalised
-Note that this can change user!
 ****************************************************************************/
-struct passwd *Get_Pwnam(char *user,BOOL allow_change)
+struct passwd *Get_Pwnam(const char *a_user)
 {
-  fstring user2;
+  fstring user;
   int last_char;
   int usernamelevel = lp_usernamelevel();
 
   struct passwd *ret;  
 
-  if (!user || !(*user))
+  if (!a_user || !(*a_user))
     return(NULL);
 
-  StrnCpy(user2,user,sizeof(user2)-1);
-
-  if (!allow_change) {
-    user = &user2[0];
-  }
+  StrnCpy(user,a_user,sizeof(user)-1);
 
   ret = _Get_Pwnam(user);
   if (ret) return(ret);
@@ -222,9 +217,6 @@ struct passwd *Get_Pwnam(char *user,BOOL allow_change)
   ret = uname_string_combinations(user, _Get_Pwnam, usernamelevel);
   if (ret) return(ret);
 
-  if (allow_change)
-    fstrcpy(user,user2);
-
   return(NULL);
 }
 
@@ -379,7 +371,7 @@ try all combinations with N uppercase letters.
 offset is the first char to try and change (start with 0)
 it assumes the string starts lowercased
 ****************************************************************************/
-static struct passwd *uname_string_combinations2(char *s,int offset,struct passwd *(*fn)(char *),int N)
+static struct passwd *uname_string_combinations2(char *s,int offset,struct passwd *(*fn)(const char *),int N)
 {
   int len = strlen(s);
   int i;
@@ -413,7 +405,7 @@ try all combinations with up to N uppercase letters.
 offset is the first char to try and change (start with 0)
 it assumes the string starts lowercased
 ****************************************************************************/
-static struct passwd * uname_string_combinations(char *s,struct passwd * (*fn)(char *),int N)
+static struct passwd * uname_string_combinations(char *s,struct passwd * (*fn)(const char *),int N)
 {
   int n;
   struct passwd *ret;

+ 11 - 10
vfs/samba/lib/util.c

@@ -101,7 +101,7 @@ pstring myhostname="";
 pstring user_socket_options="";   
 
 pstring sesssetup_user="";
-static char * const samlogon_user = "";
+static const char * const samlogon_user = "";
 
 const BOOL sam_logon_in_ssb = False;
 
@@ -115,7 +115,7 @@ char **my_netbios_names;
   find a suitable temporary directory. The result should be copied immediately
   as it may be overwritten by a subsequent call
   ****************************************************************************/
-char *tmpdir(void)
+const char *tmpdir(void)
 {
   char *p;
   if ((p = getenv("MC_TMPDIR")) || (p = getenv("TMPDIR"))) {
@@ -1748,7 +1748,7 @@ int interpret_protocol(char *str,int def)
 /****************************************************************************
 interpret an internet address or name into an IP address in 4 byte form
 ****************************************************************************/
-uint32 interpret_addr(char *str)
+uint32 interpret_addr(const char *str)
 {
   struct hostent *hp;
   uint32 res;
@@ -1787,7 +1787,7 @@ uint32 interpret_addr(char *str)
 /*******************************************************************
   a convenient addition to interpret_addr()
   ******************************************************************/
-struct in_addr *interpret_addr2(char *str)
+struct in_addr *interpret_addr2(const char *str)
 {
   static struct in_addr ret;
   uint32 a = interpret_addr(str);
@@ -1991,7 +1991,7 @@ static char *automount_lookup(char *user_name)
  This is Luke's original function with the NIS lookup code
  moved out to a separate function.
 *******************************************************************/
-static char *automount_server(char *user_name)
+static char *automount_server(const char *user_name)
 {
 	static pstring server_name;
 
@@ -2066,7 +2066,7 @@ void standard_sub_basic(char *str)
 	char *s, *p;
 	char pidstr[10];
 	struct passwd *pass;
-	char *username = sam_logon_in_ssb ? samlogon_user : sesssetup_user;
+	const char *username = sam_logon_in_ssb ? samlogon_user : sesssetup_user;
 
 	for (s = str ; s && *s && (p = strchr(s,'%')); s = p )
 	{
@@ -2074,7 +2074,7 @@ void standard_sub_basic(char *str)
 		{
 			case 'G' :
 			{
-				if ((pass = Get_Pwnam(username,False))!=NULL)
+				if ((pass = Get_Pwnam(username))!=NULL)
 				{
 					string_sub(p,"%G",gidtoname(pass->pw_gid));
 				}
@@ -2154,7 +2154,8 @@ do some standard substitutions in a string
 ****************************************************************************/
 void standard_sub(connection_struct *conn,char *str)
 {
-	char *p, *s, *home;
+	char *p, *s;
+	const char *home;
 
 	for (s=str; (p=strchr(s, '%'));s=p) {
 		switch (*(p+1)) {
@@ -2324,9 +2325,9 @@ uid_t nametouid(const char *name)
 /*******************************************************************
 something really nasty happened - panic!
 ********************************************************************/
-void smb_panic(char *why)
+void smb_panic(const char *why)
 {
-	char *cmd = lp_panic_action();
+	const char *cmd = lp_panic_action();
 	if (cmd && *cmd) {
 		system(cmd);
 	}

Some files were not shown because too many files changed in this diff