Source-Changes-HG archive

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

[src/trunk]: src/sys/external/bsd kill sprintf



details:   https://anonhg.NetBSD.org/src/rev/f18646ae0a85
branches:  trunk
changeset: 328068:f18646ae0a85
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Mar 25 15:33:22 2014 +0000

description:
kill sprintf

diffstat:

 sys/external/bsd/drm/dist/libdrm/nouveau/nouveau_dma.h       |   2 +-
 sys/external/bsd/drm/dist/libdrm/xf86drm.c                   |   8 ++-
 sys/external/bsd/drm/dist/libdrm/xf86drmMode.c               |   6 ++-
 sys/external/bsd/drm/dist/tests/dristat.c                    |   4 +-
 sys/external/bsd/drm/dist/tests/drmstat.c                    |  22 ++++++------
 sys/external/bsd/drm2/dist/drm/drm_debugfs.c                 |   2 +-
 sys/external/bsd/drm2/dist/drm/drm_pci.c                     |  13 +++---
 sys/external/bsd/drm2/dist/drm/drm_platform.c                |   7 +--
 sys/external/bsd/drm2/dist/drm/drm_proc.c                    |   4 +-
 sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c  |   4 +-
 sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_proc.c |   2 +-
 11 files changed, 38 insertions(+), 36 deletions(-)

diffs (truncated from 306 to 300 lines):

diff -r 8ae09425b785 -r f18646ae0a85 sys/external/bsd/drm/dist/libdrm/nouveau/nouveau_dma.h
--- a/sys/external/bsd/drm/dist/libdrm/nouveau/nouveau_dma.h    Tue Mar 25 15:28:15 2014 +0000
+++ b/sys/external/bsd/drm/dist/libdrm/nouveau/nouveau_dma.h    Tue Mar 25 15:33:22 2014 +0000
@@ -136,7 +136,7 @@
                       dma->push_free, faulty);
                return;
        }
-       sprintf(faulty,"%s:%d",file,line);
+       snprintf(faulty, sizeof(faulty), "%s:%d", file, line);
 #endif
 
        nouveau_dma_space(chan, (size + 1));
diff -r 8ae09425b785 -r f18646ae0a85 sys/external/bsd/drm/dist/libdrm/xf86drm.c
--- a/sys/external/bsd/drm/dist/libdrm/xf86drm.c        Tue Mar 25 15:28:15 2014 +0000
+++ b/sys/external/bsd/drm/dist/libdrm/xf86drm.c        Tue Mar 25 15:33:22 2014 +0000
@@ -292,7 +292,8 @@
     uid_t           user    = DRM_DEV_UID;
     gid_t           group   = DRM_DEV_GID, serv_group;
     
-    sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, minor);
+    snprintf(buf, sizeof(buf), type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME,
+       DRM_DIR_NAME, minor);
     drmMsg("drmOpenDevice: node name is %s\n", buf);
 
     if (drm_server_info) {
@@ -399,7 +400,8 @@
     if (create)
        return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type);
     
-    sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, minor);
+    snprintf(buf, sizeof(buf), type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME,
+       DRM_DIR_NAME, minor);
     if ((fd = open(buf, O_RDWR, 0)) >= 0)
        return fd;
     return -errno;
@@ -553,7 +555,7 @@
        char *driver, *pt, *devstring;
        int  retcode;
        
-       sprintf(proc_name, "/proc/dri/%d/name", i);
+       snprintf(proc_name, sizeof(proc_name), "/proc/dri/%d/name", i);
        if ((fd = open(proc_name, 0, 0)) >= 0) {
            retcode = read(fd, buf, sizeof(buf)-1);
            close(fd);
diff -r 8ae09425b785 -r f18646ae0a85 sys/external/bsd/drm/dist/libdrm/xf86drmMode.c
--- a/sys/external/bsd/drm/dist/libdrm/xf86drmMode.c    Tue Mar 25 15:28:15 2014 +0000
+++ b/sys/external/bsd/drm/dist/libdrm/xf86drmMode.c    Tue Mar 25 15:33:22 2014 +0000
@@ -585,7 +585,8 @@
        if (ret != 4)
                return -EINVAL;
 
-       sprintf(pci_dev_dir, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/drm",
+       snprintf(pci_dev_dir, sizeof(pci_dev_dir),
+               "/sys/bus/pci/devices/%04x:%02x:%02x.%d/drm",
                domain, bus, dev, func);
 
        sysdir = opendir(pci_dev_dir);
@@ -604,7 +605,8 @@
                        return 0;
        }
 
-       sprintf(pci_dev_dir, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/",
+       snprintf(pci_dev_dir, sizeof(pci_dev_dir),
+               "/sys/bus/pci/devices/%04x:%02x:%02x.%d/",
                domain, bus, dev, func);
 
        sysdir = opendir(pci_dev_dir);
diff -r 8ae09425b785 -r f18646ae0a85 sys/external/bsd/drm/dist/tests/dristat.c
--- a/sys/external/bsd/drm/dist/tests/dristat.c Tue Mar 25 15:28:15 2014 +0000
+++ b/sys/external/bsd/drm/dist/tests/dristat.c Tue Mar 25 15:33:22 2014 +0000
@@ -130,7 +130,7 @@
     printf("    a   pid   uid      magic     ioctls   prog\n");
 
     for (i = 0; !drmGetClient(fd, i, &auth, &pid, &uid, &magic, &iocs); i++) {
-       sprintf(buf, "/proc/%d/cmdline", pid);
+       snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
        memset(cmd, 0, sizeof(cmd));
        if ((procfd = open(buf, O_RDONLY, 0)) >= 0) {
            read(procfd, cmd, sizeof(cmd)-1);
@@ -262,7 +262,7 @@
        }
 
     for (i = 0; i < 16; i++) if (!minor || i == minor) {
-       sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, i);
+       snprintf(buf, sizeof(buf), DRM_DEV_NAME, DRM_DIR_NAME, i);
        fd = drmOpenMinor(i, 1, DRM_NODE_RENDER);
        if (fd >= 0) {
            printf("%s\n", buf);
diff -r 8ae09425b785 -r f18646ae0a85 sys/external/bsd/drm/dist/tests/drmstat.c
--- a/sys/external/bsd/drm/dist/tests/drmstat.c Tue Mar 25 15:28:15 2014 +0000
+++ b/sys/external/bsd/drm/dist/tests/drmstat.c Tue Mar 25 15:33:22 2014 +0000
@@ -218,7 +218,7 @@
                       info->list[i].high_mark);
            }
            printf("===== /proc/dri/0/mem =====\n");
-           sprintf(buf, "cat /proc/dri/0/mem");
+           snprintf(buf, sizeof(buf), "cat /proc/dri/0/mem");
            system(buf);
 #if 1
            if (!(bufs = drmMapBufs(fd))) {
@@ -234,7 +234,7 @@
                        bufs->list[i].address);
            }
            printf("===== /proc/dri/0/vma =====\n");
-           sprintf(buf, "cat /proc/dri/0/vma");
+           snprintf(buf, sizeof(buf), "cat /proc/dri/0/vma");
            system(buf);
 #endif
            break;
@@ -249,7 +249,7 @@
            }
            printf("0x%08lx:0x%04lx added\n", offset, size);
            printf("===== /proc/dri/0/mem =====\n");
-           sprintf(buf, "cat /proc/dri/0/mem");
+           snprintf(buf, sizeof(buf), "cat /proc/dri/0/mem");
            system(buf);
            break;
        case 'r':
@@ -266,7 +266,7 @@
            }
            printf("0x%08lx:0x%04lx added\n", offset, size);
            printf("===== /proc/dri/0/mem =====\n");
-           sprintf(buf, "cat /proc/dri/0/mem");
+           snprintf(buf, sizeof(buf), "cat /proc/dri/0/mem");
            system(buf);
            break;
        case 's':
@@ -279,7 +279,7 @@
                return 1;
            }
            printf("0x%04lx byte shm added at 0x%08lx\n", size, handle);
-           sprintf(buf, "cat /proc/dri/0/vm");
+           snprintf(buf, sizeof(buf), "cat /proc/dri/0/vm");
            system(buf);
            break;
        case 'P':
@@ -293,11 +293,11 @@
            printf("0x%08lx:0x%04lx mapped at %p for pid %d\n",
                   offset, size, address, getpid());
            printf("===== /proc/dri/0/vma =====\n");
-           sprintf(buf, "cat /proc/dri/0/vma");
+           snprintf(buf, sizeof(buf), "cat /proc/dri/0/vma");
            system(buf);
            mprotect((void *)offset, size, PROT_READ);
            printf("===== /proc/dri/0/vma =====\n");
-           sprintf(buf, "cat /proc/dri/0/vma");
+           snprintf(buf, sizeof(buf), "cat /proc/dri/0/vma");
            system(buf);
            break;
        case 'w':
@@ -312,13 +312,13 @@
            printf("0x%08lx:0x%04lx mapped at %p for pid %d\n",
                   offset, size, address, getpid());
            printf("===== /proc/%d/maps =====\n", getpid());
-           sprintf(buf, "cat /proc/%d/maps", getpid());
+           snprintf(buf, sizeof(buf), "cat /proc/%d/maps", getpid());
            system(buf);
            printf("===== /proc/dri/0/mem =====\n");
-           sprintf(buf, "cat /proc/dri/0/mem");
+           snprintf(buf, sizeof(buf), "cat /proc/dri/0/mem");
            system(buf);
            printf("===== /proc/dri/0/vma =====\n");
-           sprintf(buf, "cat /proc/dri/0/vma");
+           snprintf(buf, sizeof(buf), "cat /proc/dri/0/vma");
            system(buf);
            printf("===== READING =====\n");
            for (i = 0; i < 0x10; i++)
@@ -336,7 +336,7 @@
                printf("%02x ", (unsigned int)((unsigned char *)address)[i]);
            printf("\n");
            printf("===== /proc/dri/0/vma =====\n");
-           sprintf(buf, "cat /proc/dri/0/vma");
+           snprintf(buf, sizeof(buf), "cat /proc/dri/0/vma");
            system(buf);
            break;
        case 'L':
diff -r 8ae09425b785 -r f18646ae0a85 sys/external/bsd/drm2/dist/drm/drm_debugfs.c
--- a/sys/external/bsd/drm2/dist/drm/drm_debugfs.c      Tue Mar 25 15:28:15 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_debugfs.c      Tue Mar 25 15:33:22 2014 +0000
@@ -150,7 +150,7 @@
 
        INIT_LIST_HEAD(&minor->debugfs_list);
        mutex_init(&minor->debugfs_lock);
-       sprintf(name, "%d", minor_id);
+       snprintf(name, sizeof(name), "%d", minor_id);
        minor->debugfs_root = debugfs_create_dir(name, root);
        if (!minor->debugfs_root) {
                DRM_ERROR("Cannot create /sys/kernel/debug/dri/%s\n", name);
diff -r 8ae09425b785 -r f18646ae0a85 sys/external/bsd/drm2/dist/drm/drm_pci.c
--- a/sys/external/bsd/drm2/dist/drm/drm_pci.c  Tue Mar 25 15:28:15 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_pci.c  Tue Mar 25 15:33:22 2014 +0000
@@ -177,16 +177,15 @@
        } else
                master->unique_len = len;
 
-       dev->devname =
-               kmalloc(strlen(pdriver->name) +
-                       master->unique_len + 2, GFP_KERNEL);
+       size_t devlen = strlen(pdriver->name) + master->unique_len + 2;
+       dev->devname = kmalloc(dev->devlen, GFP_KERNEL);
 
        if (dev->devname == NULL) {
                ret = -ENOMEM;
                goto err;
        }
 
-       sprintf(dev->devname, "%s@%s", pdriver->name,
+       snprintf(dev->devname, devlen, "%s@%s", pdriver->name,
                master->unique);
 
        return 0;
@@ -217,14 +216,14 @@
        master->unique[master->unique_len] = '\0';
 
        bus_name = dev->driver->bus->get_name(dev);
-       dev->devname = kmalloc(strlen(bus_name) +
-                              strlen(master->unique) + 2, GFP_KERNEL);
+       size_t devlen = strlen(bus_name) + strlen(master->unique) + 2;
+       dev->devname = kmalloc(devlen, GFP_KERNEL);
        if (!dev->devname) {
                ret = -ENOMEM;
                goto err;
        }
 
-       sprintf(dev->devname, "%s@%s", bus_name,
+       snprintf(dev->devname, devlen, "%s@%s", bus_name,
                master->unique);
 
        /* Return error if the busid submitted doesn't match the device's actual
diff -r 8ae09425b785 -r f18646ae0a85 sys/external/bsd/drm2/dist/drm/drm_platform.c
--- a/sys/external/bsd/drm2/dist/drm/drm_platform.c     Tue Mar 25 15:28:15 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_platform.c     Tue Mar 25 15:33:22 2014 +0000
@@ -147,16 +147,15 @@
                goto err;
        }
 
-       dev->devname =
-               kmalloc(strlen(dev->platformdev->name) +
-                       master->unique_len + 2, GFP_KERNEL);
+       size_t devlen = strlen(dev->platformdev->name) + master->unique_len + 2;
+       dev->devname = kmalloc(devlen, GFP_KERNEL);
 
        if (dev->devname == NULL) {
                ret = -ENOMEM;
                goto err;
        }
 
-       sprintf(dev->devname, "%s@%s", dev->platformdev->name,
+       snprintf(dev->devname, devlen, "%s@%s", dev->platformdev->name,
                master->unique);
        return 0;
 err:
diff -r 8ae09425b785 -r f18646ae0a85 sys/external/bsd/drm2/dist/drm/drm_proc.c
--- a/sys/external/bsd/drm2/dist/drm/drm_proc.c Tue Mar 25 15:28:15 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_proc.c Tue Mar 25 15:33:22 2014 +0000
@@ -153,7 +153,7 @@
        int ret;
 
        INIT_LIST_HEAD(&minor->proc_nodes.list);
-       sprintf(name, "%d", minor_id);
+       snprintf(name, sizeof(name), "%d", minor_id);
        minor->proc_root = proc_mkdir(name, root);
        if (!minor->proc_root) {
                DRM_ERROR("Cannot create /proc/dri/%s\n", name);
@@ -212,7 +212,7 @@
 
        drm_proc_remove_files(drm_proc_list, DRM_PROC_ENTRIES, minor);
 
-       sprintf(name, "%d", minor->index);
+       snprintf(name, sizeof(name), "%d", minor->index);
        remove_proc_entry(name, root);
 
        return 0;
diff -r 8ae09425b785 -r f18646ae0a85 sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
--- a/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c       Tue Mar 25 15:28:15 2014 +0000
+++ b/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c       Tue Mar 25 15:33:22 2014 +0000
@@ -2234,7 +2234,7 @@
        vchiq_log_trace(vchiq_susp_log_level, "%s", __func__);
 
        if (use_type == USE_TYPE_VCHIQ) {
-               sprintf(entity, "VCHIQ:   ");
+               snprintf(entity, sizeof(entity), "VCHIQ:   ");
                entity_uc = &arm_state->peer_use_count;
        } else if (service) {
                snprintf(entity, sizeof(entity), "%c%c%c%c:%8x",
@@ -2370,7 +2370,7 @@
                        service->client_id);
                entity_uc = &service->service_use_count;
        } else {
-               sprintf(entity, "PEER:   ");
+               snprintf(entity, sizeof(entity), "PEER:   ");
                entity_uc = &arm_state->peer_use_count;
        }
 
diff -r 8ae09425b785 -r f18646ae0a85 sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_proc.c
--- a/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_proc.c      Tue Mar 25 15:28:15 2014 +0000
+++ b/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_proc.c      Tue Mar 25 15:33:22 2014 +0000
@@ -94,7 +94,7 @@
                break;
        }



Home | Main Index | Thread Index | Old Index