[PATCH] s4/torture: make --unclist active with smb2 testcases

Jeremy Allison jra at samba.org
Fri Aug 25 22:13:00 UTC 2017


On Fri, Aug 25, 2017 at 03:01:53PM +0000, Peter Somogyi via samba-technical wrote:
> Volker has just notified me TALLOC_FREE doesn't need NULL check.
> Here is the simplified version (retested), formatted to the usual 
> free-before-return style.

Hi Peter, unfortunately this doesn't compile:

You need to add:

+#include "source4/torture/util.h"

to source4/torture/smb2/util.c to get the definition
of torture_get_conn_index(), and when you do:

In this hunk:

diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c
index 52a63dd..b160352 100644
--- a/source4/torture/smb2/util.c
+++ b/source4/torture/smb2/util.c
@@ -385,6 +385,22 @@ bool torture_smb2_connection_ext(struct torture_context *tctx,
        NTSTATUS status;
        const char *host = torture_setting_string(tctx, "host", NULL);
        const char *share = torture_setting_string(tctx, "share", NULL);
+       const char *p = torture_setting_string(tctx, "unclist", NULL);
+       TALLOC_CTX *mem_ctx = NULL;
+       bool ok;
+
+       if (p != NULL) {
+               mem_ctx = talloc_new(tctx);
+               if (mem_ctx == NULL) {
+                       return false;
+               }
+               ok = torture_get_conn_index(tctx->conn_index++, mem_ctx, tctx,
+                                           &host, &share);
+               if (!ok) {
+                       TALLOC_FREE(mem_ctx);
+                       return false;
+               }
+       }

the call to torture_get_conn_index() fails to compile as
&host and &share are pointers to const char *, and
torture_get_conn_index() wants char **.

You need to copy the returned host and share strings
using talloc_strdup() first before you can pass them
to torture_get_conn_index().



More information about the samba-technical mailing list