]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
logfmtpacket(): drop useless local variables
authorMichał Kępień <michal@isc.org>
Tue, 31 Dec 2024 04:40:48 +0000 (05:40 +0100)
committerMichał Kępień <michal@isc.org>
Tue, 31 Dec 2024 04:40:48 +0000 (05:40 +0100)
All callers of the logfmtpacket() helper function require the argument
passed as 'address' to be non-NULL.  Meanwhile, the 'newline' and
'space' local variables in logfmtpacket() are only set to values
different than their initial values if the 'address' parameter is NULL.
Replace the 'newline' and 'space' local variables in logfmtpacket() with
fixed strings to improve code readability.

lib/dns/message.c

index bb83ff41d772d247660f2f5b0164a30672f3d897..a5324eb10e9f27db13d234b4135cbe828051b138 100644 (file)
@@ -4755,8 +4755,6 @@ logfmtpacket(dns_message_t *message, const char *description,
             isc_logmodule_t module, const dns_master_style_t *style, int level,
             isc_mem_t *mctx) {
        char addrbuf[ISC_SOCKADDR_FORMATSIZE] = { 0 };
-       const char *newline = "\n";
-       const char *space = " ";
        isc_buffer_t buffer;
        char *buf = NULL;
        int len = 1024;
@@ -4773,8 +4771,6 @@ logfmtpacket(dns_message_t *message, const char *description,
 
        if (address != NULL) {
                isc_sockaddr_format(address, addrbuf, sizeof(addrbuf));
-       } else {
-               newline = space = "";
        }
 
        do {
@@ -4785,8 +4781,8 @@ logfmtpacket(dns_message_t *message, const char *description,
                        isc_mem_put(mctx, buf, len);
                        len += 1024;
                } else if (result == ISC_R_SUCCESS) {
-                       isc_log_write(category, module, level, "%s%s%s%s%.*s",
-                                     description, space, addrbuf, newline,
+                       isc_log_write(category, module, level, "%s %s\n%.*s",
+                                     description, addrbuf,
                                      (int)isc_buffer_usedlength(&buffer), buf);
                }
        } while (result == ISC_R_NOSPACE);