Date: Fri, 20 May 2016 11:46:04 -0600 From: Scott Long <scott4long@yahoo.com> To: Steven Hartland <steven@multiplay.co.uk> Cc: Scott Long <scottl@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "svn-src-head@freebsd.org" <svn-src-head@freebsd.org> Subject: Re: svn commit: r300219 - in head/sys: kern sys Message-ID: <20F58791-903E-48A1-A57C-D28ED10ABEBC@yahoo.com> In-Reply-To: <4596681286066293430@unknownmsgid> References: <201605191714.u4JHEOnn037348@repo.freebsd.org> <4596681286066293430@unknownmsgid>
next in thread | previous in thread | raw e-mail | index | archive | help
Yeah, I was following existing style. Feel free to fix up if you like. Scott > On May 19, 2016, at 12:51 PM, Steven Hartland <steven@multiplay.co.uk> wrote: > > I thought it was considered better to use if (var == NULL) instead of > if (!var) for pointers as they aren't bools? > >> On 19 May 2016, at 18:14, Scott Long <scottl@freebsd.org> wrote: >> >> Author: scottl >> Date: Thu May 19 17:14:24 2016 >> New Revision: 300219 >> URL: https://svnweb.freebsd.org/changeset/base/300219 >> >> Log: >> Adjust the creation of tq_name so it can be freed correctly >> >> Reviewed by: jhb, allanjude >> Differential Revision: D6454 >> >> Modified: >> head/sys/kern/subr_taskqueue.c >> head/sys/sys/taskqueue.h >> >> Modified: head/sys/kern/subr_taskqueue.c >> ============================================================================== >> --- head/sys/kern/subr_taskqueue.c Thu May 19 17:02:33 2016 (r300218) >> +++ head/sys/kern/subr_taskqueue.c Thu May 19 17:14:24 2016 (r300219) >> @@ -128,16 +128,17 @@ _taskqueue_create(const char *name, int >> int mtxflags, const char *mtxname __unused) >> { >> struct taskqueue *queue; >> - char *tq_name = NULL; >> + char *tq_name; >> >> - if (name != NULL) >> - tq_name = strndup(name, 32, M_TASKQUEUE); >> - if (tq_name == NULL) >> - tq_name = "taskqueue"; >> + tq_name = malloc(TASKQUEUE_NAMELEN, M_TASKQUEUE, mflags | M_ZERO); >> + if (!tq_name) >> + return (NULL); >> + >> + snprintf(tq_name, TASKQUEUE_NAMELEN, "%s", (name) ? name : "taskqueue"); >> >> queue = malloc(sizeof(struct taskqueue), M_TASKQUEUE, mflags | M_ZERO); >> if (!queue) >> - return NULL; >> + return (NULL); >> >> STAILQ_INIT(&queue->tq_queue); >> TAILQ_INIT(&queue->tq_active); >> @@ -153,7 +154,7 @@ _taskqueue_create(const char *name, int >> queue->tq_flags |= TQ_FLAGS_UNLOCKED_ENQUEUE; >> mtx_init(&queue->tq_mutex, tq_name, NULL, mtxflags); >> >> - return queue; >> + return (queue); >> } >> >> struct taskqueue * >> >> Modified: head/sys/sys/taskqueue.h >> ============================================================================== >> --- head/sys/sys/taskqueue.h Thu May 19 17:02:33 2016 (r300218) >> +++ head/sys/sys/taskqueue.h Thu May 19 17:14:24 2016 (r300219) >> @@ -56,6 +56,7 @@ enum taskqueue_callback_type { >> #define TASKQUEUE_CALLBACK_TYPE_MIN TASKQUEUE_CALLBACK_TYPE_INIT >> #define TASKQUEUE_CALLBACK_TYPE_MAX TASKQUEUE_CALLBACK_TYPE_SHUTDOWN >> #define TASKQUEUE_NUM_CALLBACKS TASKQUEUE_CALLBACK_TYPE_MAX + 1 >> +#define TASKQUEUE_NAMELEN 32 >> >> typedef void (*taskqueue_callback_fn)(void *context); >> >> >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20F58791-903E-48A1-A57C-D28ED10ABEBC>
