Use provided buffer in dns_resource_key_to_string
When the buffer is allocated on the stack we do not have to check for failure everywhere. This is especially useful in debug statements, because we can put dns_resource_key_to_string() call in the debug statement, and we do not need a seperate if (log_level >= LOG_DEBUG) for the conversion. dns_resource_key_to_string() is changed not to provide any whitespace padding. Most callers were stripping the whitespace with strstrip(), and it did not look to well anyway. systemd-resolve output is not column aligned anymore. The result of the conversion is not stored in DnsTransaction object anymore. It is used only for debugging, so it seems fine to generate it when needed. Various debug statements are extended to provide more information.
This commit is contained in:
@@ -19,7 +19,23 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "string-util.h"
|
||||
|
||||
const char *af_to_name(int id);
|
||||
int af_from_name(const char *name);
|
||||
|
||||
static inline const char* af_to_name_short(int id) {
|
||||
const char *f;
|
||||
|
||||
if (id == AF_UNSPEC)
|
||||
return "*";
|
||||
|
||||
f = af_to_name(id);
|
||||
if (!f)
|
||||
return "unknown";
|
||||
|
||||
assert(startswith(f, "AF_"));
|
||||
return f + 3;
|
||||
}
|
||||
|
||||
int af_max(void);
|
||||
|
||||
Reference in New Issue
Block a user