Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Turn a workqueue(9) name into an array in the struc...



details:   https://anonhg.NetBSD.org/src/rev/878900375df3
branches:  trunk
changeset: 770572:878900375df3
user:      jym <jym%NetBSD.org@localhost>
date:      Sun Oct 23 21:41:23 2011 +0000

description:
Turn a workqueue(9) name into an array in the struct workqueue, rather
than a const char *. This avoids keeping a reference to a string
owned by caller (string could be allocated on stack).

diffstat:

 sys/kern/subr_workqueue.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r 24bfe69fb183 -r 878900375df3 sys/kern/subr_workqueue.c
--- a/sys/kern/subr_workqueue.c Sun Oct 23 21:15:02 2011 +0000
+++ b/sys/kern/subr_workqueue.c Sun Oct 23 21:41:23 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_workqueue.c,v 1.31 2011/07/27 14:35:34 uebayasi Exp $     */
+/*     $NetBSD: subr_workqueue.c,v 1.32 2011/10/23 21:41:23 jym Exp $  */
 
 /*-
  * Copyright (c)2002, 2005, 2006, 2007 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.31 2011/07/27 14:35:34 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.32 2011/10/23 21:41:23 jym Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -58,7 +58,7 @@
        void *wq_arg;
        int wq_flags;
 
-       const char *wq_name;
+       char wq_name[MAXCOMLEN];
        pri_t wq_prio;
        void *wq_ptr;
 };
@@ -142,8 +142,9 @@
     pri_t prio, int ipl)
 {
 
+       strncpy(wq->wq_name, name, sizeof(wq->wq_name));
+
        wq->wq_prio = prio;
-       wq->wq_name = name;
        wq->wq_func = callback_func;
        wq->wq_arg = callback_arg;
 }



Home | Main Index | Thread Index | Old Index