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: >=20 > I thought it was considered better to use if (var =3D=3D NULL) instead = of > if (!var) for pointers as they aren't bools? >=20 >> On 19 May 2016, at 18:14, Scott Long <scottl@freebsd.org> wrote: >>=20 >> Author: scottl >> Date: Thu May 19 17:14:24 2016 >> New Revision: 300219 >> URL: https://svnweb.freebsd.org/changeset/base/300219 >>=20 >> Log: >> Adjust the creation of tq_name so it can be freed correctly >>=20 >> Reviewed by: jhb, allanjude >> Differential Revision: D6454 >>=20 >> Modified: >> head/sys/kern/subr_taskqueue.c >> head/sys/sys/taskqueue.h >>=20 >> Modified: head/sys/kern/subr_taskqueue.c >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- 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 =3D NULL; >> + char *tq_name; >>=20 >> - if (name !=3D NULL) >> - tq_name =3D strndup(name, 32, M_TASKQUEUE); >> - if (tq_name =3D=3D NULL) >> - tq_name =3D "taskqueue"; >> + tq_name =3D malloc(TASKQUEUE_NAMELEN, M_TASKQUEUE, mflags | = M_ZERO); >> + if (!tq_name) >> + return (NULL); >> + >> + snprintf(tq_name, TASKQUEUE_NAMELEN, "%s", (name) ? name : = "taskqueue"); >>=20 >> queue =3D malloc(sizeof(struct taskqueue), M_TASKQUEUE, mflags | = M_ZERO); >> if (!queue) >> - return NULL; >> + return (NULL); >>=20 >> STAILQ_INIT(&queue->tq_queue); >> TAILQ_INIT(&queue->tq_active); >> @@ -153,7 +154,7 @@ _taskqueue_create(const char *name, int >> queue->tq_flags |=3D TQ_FLAGS_UNLOCKED_ENQUEUE; >> mtx_init(&queue->tq_mutex, tq_name, NULL, mtxflags); >>=20 >> - return queue; >> + return (queue); >> } >>=20 >> struct taskqueue * >>=20 >> Modified: head/sys/sys/taskqueue.h >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- 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 >>=20 >> typedef void (*taskqueue_callback_fn)(void *context); >>=20 >>=20 >=20
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20F58791-903E-48A1-A57C-D28ED10ABEBC>