]> granicus.if.org Git - spl/commitdiff
3 minor fixups where sprintf() was used instead of snprintf() with
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Tue, 4 Nov 2008 23:30:15 +0000 (23:30 +0000)
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Tue, 4 Nov 2008 23:30:15 +0000 (23:30 +0000)
a known max length.  Additionally the function return value is cast
to void to make it explicit that the value is not needed.

git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@172 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c

modules/spl/spl-proc.c
modules/spl/spl-vnode.c
modules/splat/splat-kmem.c

index 017c69d470b5927b1a51783ef86fd45615884411..bf185c60ec32704d850c39313abc089c56b18d44 100644 (file)
@@ -446,7 +446,7 @@ proc_dohostid(struct ctl_table *table, int write, struct file *filp,
                        RETURN(-EINVAL);
 
                spl_hostid = (long)val;
-                sprintf(hw_serial, "%u", (val >= 0) ? val : -val);
+                (void)snprintf(hw_serial, 11, "%u", (val >= 0) ? val : -val);
                 *ppos += *lenp;
         } else {
                 len = snprintf(str, sizeof(str), "%lx", spl_hostid);
index 17336a1a22503e757c0d9778af2ad85741503dc9..fef74f3c7a209d2abdd0b2c90c0ef56a59c4489a 100644 (file)
@@ -161,18 +161,18 @@ vn_openat(const char *path, uio_seg_t seg, int flags, int mode,
          vnode_t **vpp, int x1, void *x2, vnode_t *vp, int fd)
 {
        char *realpath;
-       int rc;
+       int len, rc;
        ENTRY;
 
        ASSERT(vp == rootdir);
 
-       realpath = kmalloc(strlen(path) + 2, GFP_KERNEL);
+       len = strlen(path) + 2;
+       realpath = kmalloc(len, GFP_KERNEL);
        if (!realpath)
                RETURN(ENOMEM);
 
-       sprintf(realpath, "/%s", path);
+       (void)snprintf(realpath, len, "/%s", path);
        rc = vn_open(realpath, seg, flags, mode, vpp, x1, x2);
-
        kfree(realpath);
 
        RETURN(rc);
index bc15bc64ac0a464659a47913031ad4b017319df1..7e95b4af887cda8294f5769c3c8859f8c72ed59b 100644 (file)
@@ -601,7 +601,8 @@ splat_kmem_test8_sc(struct file *file, void *arg, int size, int count)
                spin_lock_init(&kcp.kcp_lock);
                init_waitqueue_head(&kcp.kcp_waitq);
 
-               sprintf(cache_name, "%s-%d-%d", SPLAT_KMEM_CACHE_NAME, size, i);
+               (void)snprintf(cache_name, 32, "%s-%d-%d",
+                              SPLAT_KMEM_CACHE_NAME, size, i);
                kcp.kcp_cache = kmem_cache_create(cache_name, kcp.kcp_size, 0,
                                          splat_kmem_cache_test_constructor,
                                          splat_kmem_cache_test_destructor,