Make char* parameters const
authorDerrell Lipman <derrell.lipman@unwireduniverse.com>
Mon, 23 Feb 2009 18:50:11 +0000 (13:50 -0500)
committerDerrell Lipman <derrell.lipman@unwireduniverse.com>
Mon, 23 Feb 2009 18:50:25 +0000 (13:50 -0500)
- Use const in function signatures whenever appropriate, to help prevent
  errant scribbling on users' buffers. smbc_set_credentials() always acted as
  if its formal parameters were const char *, and changing the formal
  declaration to specify that should not cause any change to the ABI. It is
  still allowable to pass a writable buffer to a function which specifies that
  it will not write to the buffer.

  I'm making this change only in master.

Derrell

source3/include/libsmbclient.h
source3/libsmb/libsmb_context.c

index 8c642b1794cd6354a86016c8be1300253c2c9bfa..869aeb6a032336512c101f528e61f07041cc95c5 100644 (file)
@@ -2677,11 +2677,11 @@ smbc_version(void);
  */
 
 void
-smbc_set_credentials(char *workgroup,
-                     char *user,
-                     char *password,
+smbc_set_credentials(const char *workgroup,
+                     const char *user,
+                     const char *password,
                      smbc_bool use_kerberos,
-                     char *signing_state);
+                     const char *signing_state);
 
 /*
  * Wrapper around smbc_set_credentials.
index c7c9903b7611e83ed9264c3a60cde59b567a1ec0..4c12d18ab7b62a7dca92a2f22e671f6a9e27ab61 100644 (file)
@@ -630,11 +630,11 @@ smbc_version(void)
  * Set the credentials so DFS will work when following referrals.
  */
 void
-smbc_set_credentials(char *workgroup,
-                     char *user,
-                     char *password,
+smbc_set_credentials(const char *workgroup,
+                     const char *user,
+                     const char *password,
                      smbc_bool use_kerberos,
-                     char *signing_state)
+                     const char *signing_state)
 {
         struct user_auth_info *auth_info;
 
@@ -681,18 +681,8 @@ void smbc_set_credentials_with_fallback(SMBCCTX *context,
                signing_state = "force";
        }
 
-       /* Using CONST_DISCARD here is ugly, but
-        * we know that smbc_set_credentials() doesn't
-        * actually modify the strings, and should have
-        * been const from the start. We're constrained
-        * by the ABI here.
-        */
-
-       smbc_set_credentials(CONST_DISCARD(char *,workgroup),
-                            CONST_DISCARD(char *,user),
-                            CONST_DISCARD(char *,password),
-                            use_kerberos,
-                            CONST_DISCARD(char *,signing_state));
+       smbc_set_credentials(workgroup, user, password,
+                             use_kerberos, signing_state);
 
        if (smbc_getOptionFallbackAfterKerberos(context)) {
                cli_cm_set_fallback_after_kerberos();