summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2022-11-28 11:01:16 +0100
committerJeremy Allison <jra@samba.org>2022-12-14 04:32:34 +0000
commitfe8895c83c560f424edd35d9394414c2801127d2 (patch)
treebe8f8abf7c22a8c793a8396df833eaa680d1fa6f /lib/util
parentbcdbe6ef6b59ae3638f263fbd5ddf4107c3f52cf (diff)
downloadsamba-fe8895c83c560f424edd35d9394414c2801127d2.tar.gz
lib: Use talloc_asprintf_addbuf() in print_socket_options()
With the proper NULL checks we don't need the stackframe, use a passed in context instead. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/util_net.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/util/util_net.c b/lib/util/util_net.c
index a0032cca22f..8a34855b8fa 100644
--- a/lib/util/util_net.c
+++ b/lib/util/util_net.c
@@ -977,9 +977,8 @@ static const smb_socket_option socket_options[] = {
Print socket options.
****************************************************************************/
-static void print_socket_options(int s)
+static void print_socket_options(TALLOC_CTX *ctx, int s)
{
- TALLOC_CTX *frame = NULL;
const smb_socket_option *p = &socket_options[0];
char *str = NULL;
@@ -987,9 +986,7 @@ static void print_socket_options(int s)
return;
}
- frame = talloc_stackframe();
-
- str = talloc_strdup(frame, "");
+ str = talloc_strdup(ctx, "");
if (str == NULL) {
DBG_WARNING("talloc failed\n");
goto done;
@@ -1006,21 +1003,17 @@ static void print_socket_options(int s)
continue;
}
- str = talloc_asprintf_append_buffer(
- str,
+ talloc_asprintf_addbuf(
+ &str,
"%s%s=%d",
str[0] != '\0' ? ", " : "",
p->name,
val);
- if (str == NULL) {
- DBG_WARNING("talloc_asprintf_append_buffer failed\n");
- goto done;
- }
}
DEBUG(5, ("socket options: %s\n", str));
done:
- TALLOC_FREE(frame);
+ TALLOC_FREE(str);
}
/****************************************************************************
@@ -1084,8 +1077,8 @@ void set_socket_options(int fd, const char *options)
}
}
+ print_socket_options(ctx, fd);
TALLOC_FREE(ctx);
- print_socket_options(fd);
}
/*