Author: avg
Date: Fri Jun 11 19:27:21 2010
New Revision: 209062
URL: http://svn.freebsd.org/changeset/base/209062

Log:
  fix a few cases where a string is passed via format argument instead of
  via %s
  
  Most of the cases looked harmless, but this is done for the sake of
  correctness.  In one case it even allowed to drop an intermediate buffer.
  
  Found by:     clang
  MFC after:    2 week

Modified:
  head/sys/dev/acpica/acpi_thermal.c
  head/sys/dev/usb/usb_dev.c
  head/sys/dev/usb/usb_device.c
  head/sys/dev/usb/usb_process.c
  head/sys/fs/procfs/procfs_type.c
  head/sys/geom/geom_dev.c
  head/sys/kern/subr_kdb.c
  head/sys/kern/subr_taskqueue.c

Modified: head/sys/dev/acpica/acpi_thermal.c
==============================================================================
--- head/sys/dev/acpica/acpi_thermal.c  Fri Jun 11 19:17:36 2010        
(r209061)
+++ head/sys/dev/acpica/acpi_thermal.c  Fri Jun 11 19:27:21 2010        
(r209062)
@@ -1171,7 +1171,6 @@ static int
 acpi_tz_cooling_thread_start(struct acpi_tz_softc *sc)
 {
     int error;
-    char name[16];
 
     ACPI_LOCK(thermal);
     if (sc->tz_cooling_proc_running) {
@@ -1182,10 +1181,9 @@ acpi_tz_cooling_thread_start(struct acpi
     ACPI_UNLOCK(thermal);
     error = 0;
     if (sc->tz_cooling_proc == NULL) {
-       snprintf(name, sizeof(name), "acpi_cooling%d",
-           device_get_unit(sc->tz_dev));
        error = kproc_create(acpi_tz_cooling_thread, sc,
-           &sc->tz_cooling_proc, RFHIGHPID, 0, name);
+           &sc->tz_cooling_proc, RFHIGHPID, 0, "acpi_cooling%d",
+           device_get_unit(sc->tz_dev));
        if (error != 0) {
            device_printf(sc->tz_dev, "could not create thread - %d", error);
            ACPI_LOCK(thermal);

Modified: head/sys/dev/usb/usb_dev.c
==============================================================================
--- head/sys/dev/usb/usb_dev.c  Fri Jun 11 19:17:36 2010        (r209061)
+++ head/sys/dev/usb/usb_dev.c  Fri Jun 11 19:27:21 2010        (r209062)
@@ -1733,7 +1733,7 @@ usb_fifo_attach(struct usb_device *udev,
 
                /* Now, create the device itself */
                f_sc->dev = make_dev(&usb_devsw, 0, uid, gid, mode,
-                   devname);
+                   "%s", devname);
                /* XXX setting si_drv1 and creating the device is not atomic! */
                f_sc->dev->si_drv1 = pd;
        }

Modified: head/sys/dev/usb/usb_device.c
==============================================================================
--- head/sys/dev/usb/usb_device.c       Fri Jun 11 19:17:36 2010        
(r209061)
+++ head/sys/dev/usb/usb_device.c       Fri Jun 11 19:27:21 2010        
(r209062)
@@ -1577,7 +1577,7 @@ usb_alloc_device(device_t parent_dev, st
        udev->ctrl_dev = usb_make_dev(udev, 0, FREAD|FWRITE);
 
        /* Create a link from /dev/ugenX.X to the default endpoint */
-       make_dev_alias(udev->ctrl_dev, udev->ugen_name);
+       make_dev_alias(udev->ctrl_dev, "%s", udev->ugen_name);
 #endif
        if (udev->flags.usb_mode == USB_MODE_HOST) {
 

Modified: head/sys/dev/usb/usb_process.c
==============================================================================
--- head/sys/dev/usb/usb_process.c      Fri Jun 11 19:17:36 2010        
(r209061)
+++ head/sys/dev/usb/usb_process.c      Fri Jun 11 19:27:21 2010        
(r209062)
@@ -221,7 +221,7 @@ usb_proc_create(struct usb_process *up, 
        cv_init(&up->up_drain, "usbdrain");
 
        if (USB_THREAD_CREATE(&usb_process, up,
-           &up->up_ptr, pmesg)) {
+           &up->up_ptr, "%s", pmesg)) {
                DPRINTFN(0, "Unable to create USB process.");
                up->up_ptr = NULL;
                goto error;

Modified: head/sys/fs/procfs/procfs_type.c
==============================================================================
--- head/sys/fs/procfs/procfs_type.c    Fri Jun 11 19:17:36 2010        
(r209061)
+++ head/sys/fs/procfs/procfs_type.c    Fri Jun 11 19:27:21 2010        
(r209062)
@@ -48,9 +48,9 @@ procfs_doproctype(PFS_FILL_ARGS)
        static const char *none = "Not Available";
 
        if (p != NULL && p->p_sysent && p->p_sysent->sv_name)
-               sbuf_printf(sb, p->p_sysent->sv_name);
+               sbuf_printf(sb, "%s", p->p_sysent->sv_name);
        else
-               sbuf_printf(sb, none);
+               sbuf_printf(sb, "%s", none);
        sbuf_putc(sb, '\n');
        return (0);
 }

Modified: head/sys/geom/geom_dev.c
==============================================================================
--- head/sys/geom/geom_dev.c    Fri Jun 11 19:17:36 2010        (r209061)
+++ head/sys/geom/geom_dev.c    Fri Jun 11 19:27:21 2010        (r209062)
@@ -127,7 +127,7 @@ g_dev_taste(struct g_class *mp, struct g
        KASSERT(error == 0,
            ("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error));
        dev = make_dev(&g_dev_cdevsw, 0,
-           UID_ROOT, GID_OPERATOR, 0640, gp->name);
+           UID_ROOT, GID_OPERATOR, 0640, "%s", gp->name);
        if (pp->flags & G_PF_CANDELETE)
                dev->si_flags |= SI_CANDELETE;
        dev->si_iosize_max = MAXPHYS;

Modified: head/sys/kern/subr_kdb.c
==============================================================================
--- head/sys/kern/subr_kdb.c    Fri Jun 11 19:17:36 2010        (r209061)
+++ head/sys/kern/subr_kdb.c    Fri Jun 11 19:27:21 2010        (r209062)
@@ -230,7 +230,7 @@ kdb_panic(const char *msg)
        stop_cpus_hard(PCPU_GET(other_cpus));
 #endif
        printf("KDB: panic\n");
-       panic(msg);
+       panic("%s", msg);
 }
 
 void

Modified: head/sys/kern/subr_taskqueue.c
==============================================================================
--- head/sys/kern/subr_taskqueue.c      Fri Jun 11 19:17:36 2010        
(r209061)
+++ head/sys/kern/subr_taskqueue.c      Fri Jun 11 19:27:21 2010        
(r209062)
@@ -322,7 +322,7 @@ taskqueue_start_threads(struct taskqueue
        for (i = 0; i < count; i++) {
                if (count == 1)
                        error = kthread_add(taskqueue_thread_loop, tqp, NULL,
-                           &tq->tq_threads[i], RFSTOPPED, 0, ktname);
+                           &tq->tq_threads[i], RFSTOPPED, 0, "%s", ktname);
                else
                        error = kthread_add(taskqueue_thread_loop, tqp, NULL,
                            &tq->tq_threads[i], RFSTOPPED, 0,
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to