messaging3: Simplify ping_message()
authorVolker Lendecke <vl@samba.org>
Wed, 9 Jul 2014 13:17:13 +0000 (13:17 +0000)
committerVolker Lendecke <vl@samba.org>
Thu, 24 Jul 2014 19:41:10 +0000 (21:41 +0200)
The talloc_strnup was only used to \0-terminate the data for printing. The
same can be achieved by %.* in the printf format.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/lib/messages.c

index 9d77bf8021ef150b8278b86dcc637664ed7ef156..a308a09c9075c0e91cde468cc11b4e20422de42b 100644 (file)
@@ -91,17 +91,11 @@ static void ping_message(struct messaging_context *msg_ctx,
                         DATA_BLOB *data)
 {
        struct server_id_buf idbuf;
-       const char *msg = "none";
-       char *free_me = NULL;
 
-       if (data->data != NULL) {
-               free_me = talloc_strndup(talloc_tos(), (char *)data->data,
-                                        data->length);
-               msg = free_me;
-       }
-       DEBUG(1, ("INFO: Received PING message from PID %s [%s]\n",
-                 server_id_str_buf(src, &idbuf), msg));
-       TALLOC_FREE(free_me);
+       DEBUG(1, ("INFO: Received PING message from PID %s [%.*s]\n",
+                 server_id_str_buf(src, &idbuf), (int)data->length,
+                 data->data ? (char *)data->data : ""));
+
        messaging_send(msg_ctx, src, MSG_PONG, data);
 }