s3:libsmbclient: cleanup smbc_setWorkgroup() usage
authorDavid Disseldorp <ddiss@samba.org>
Wed, 16 May 2018 14:50:55 +0000 (16:50 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 16 May 2018 23:10:28 +0000 (01:10 +0200)
It now takes a const char *. There's no need to use heap memory here.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libsmb/libsmb_context.c

index 932223c9b2fb0960517ac88df561d76c74a40b68..9e7b083952f0c1ed99f773769587932917ebd3d0 100644 (file)
@@ -659,24 +659,16 @@ smbc_init_context(SMBCCTX *context)
         DEBUG(1, ("Using netbios name %s.\n", smbc_getNetbiosName(context)));
 
         if (!smbc_getWorkgroup(context)) {
-                char *workgroup;
+                const char *workgroup;
 
                 if (lp_workgroup()) {
-                        workgroup = SMB_STRDUP(lp_workgroup());
-                }
-                else {
+                        workgroup = lp_workgroup();
+                } else {
                         /* TODO: Think about a decent default workgroup */
-                        workgroup = SMB_STRDUP("samba");
-                }
-
-                if (!workgroup) {
-                        TALLOC_FREE(frame);
-                        errno = ENOMEM;
-                        return NULL;
+                        workgroup = "samba";
                 }
 
                 smbc_setWorkgroup(context, workgroup);
-               SAFE_FREE(workgroup);
 
                if (!smbc_getWorkgroup(context)) {
                         TALLOC_FREE(frame);