From a132c6d7c160ed70945cacad729efcb2e91eb84d Mon Sep 17 00:00:00 2001 From: Stathis Kamperis Date: Sat, 23 Feb 2008 14:10:37 +0200 Subject: [PATCH] Use log() instead of printf() plus fix a mem leak in prop_string_cstring() --- netbsd/cdev/mydev.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/netbsd/cdev/mydev.c b/netbsd/cdev/mydev.c index a4c4a47..4ad8130 100644 --- a/netbsd/cdev/mydev.c +++ b/netbsd/cdev/mydev.c @@ -5,6 +5,7 @@ #include #include #include +#include /* for free(9) */ #include #include #include @@ -105,8 +106,8 @@ mydevioctl(dev_t dev, u_long cmd, caddr_t data, int flags, case MYDEVOLDIOCTL: /* Pass data from userspace to kernel in the conventional way */ params = (struct mydev_params *)data; - printf("Got number of %d and string of %s\n", - params->number, params->string); + log(LOG_DEBUG, "Got number of %d and string of %s\n", + params->number, params->string); break; case MYDEVSETPROPS: @@ -117,20 +118,22 @@ mydevioctl(dev_t dev, u_long cmd, caddr_t data, int flags, return error; /* Print dict's count for debugging purposes */ - printf("count = %u\n", prop_dictionary_count(dict)); + log(LOG_DEBUG, "mydev: dict count = %u\n", + prop_dictionary_count(dict)); /* Retrieve object associated with "key" key */ ps = prop_dictionary_get(dict, "key"); if (ps == NULL || prop_object_type(ps) != PROP_TYPE_STRING) { prop_object_release(dict); - printf("prop_dictionary_get()\n"); + log(LOG_DEBUG, "mydev: prop_dictionary_get() failed\n"); return -1; } /* Print data */ val = prop_string_cstring(ps); prop_object_release(ps); - printf(" = (%s, %s)\n", "key", val == NULL ? "null" : val); + log(LOG_DEBUG, " = (%s, %s)\n", "key", val); + free(val, M_TEMP); /* Done */ prop_object_release(dict); -- 2.11.4.GIT