diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2020-05-11 22:57:21 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2020-05-11 22:57:21 +0000 |
commit | 580744621f33383027108364dcadad718df46ffe (patch) | |
tree | 187024ccf9e3ec44b623ce2db3f6e2aac3f0887f /sys/riscv/riscv | |
parent | 294b75a880e20b6c9c198533bd421650e55fb651 (diff) | |
download | src-580744621f33383027108364dcadad718df46ffe.tar.gz src-580744621f33383027108364dcadad718df46ffe.zip |
copystr(9): Move to deprecate [2/2]
Unlike the other copy*() functions, it does not serve to copy from one
address space to another or protect against potential faults. It's just
an older incarnation of the now-more-common strlcpy().
Add a coccinelle script to tools/ which can be used to mechanically
convert existing instances where replacement with strlcpy is trivial.
In the two cases which matched, fuse_vfsops.c and union_vfsops.c, the
code was further refactored manually to simplify.
Replace the declaration of copystr() in systm.h with a small macro
wrapper around strlcpy.
Remove N redundant MI implementations of copystr. For MIPS, this
entailed inlining the assembler copystr into the only consumer,
copyinstr, and making the latter a leaf function.
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D24672
Notes
Notes:
svn path=/head/; revision=360944
Diffstat (limited to 'sys/riscv/riscv')
-rw-r--r-- | sys/riscv/riscv/copystr.c | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/sys/riscv/riscv/copystr.c b/sys/riscv/riscv/copystr.c deleted file mode 100644 index 261dbc81ef76..000000000000 --- a/sys/riscv/riscv/copystr.c +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 2014 Andrew Turner - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/systm.h> - -int -copystr(const void * __restrict kfaddr, void * __restrict kdaddr, size_t len, - size_t * __restrict lencopied) -{ - const char *src; - size_t pos; - char *dst; - int error; - - error = ENAMETOOLONG; - src = kfaddr; - dst = kdaddr; - for (pos = 0; pos < len; pos++) { - dst[pos] = src[pos]; - if (src[pos] == '\0') { - /* Increment pos to hold the number of bytes copied */ - pos++; - error = 0; - break; - } - } - - if (lencopied != NULL) - *lencopied = pos; - - return (error); -} |