* libmisc/copydir.c: Do not specify a size of arrays in the

prototypes.
	* libmisc/copydir.c: Use a size_t for the length of strings.
	* libmisc/copydir.c: Cast the return value of malloc().
	* libmisc/copydir.c: The size argument of write() is a size_t.
This commit is contained in:
nekral-guest 2008-06-13 20:10:53 +00:00
parent 232bcafd7c
commit 7d05c4a2b0
2 changed files with 23 additions and 15 deletions

View File

@ -1,3 +1,11 @@
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/copydir.c: Do not specify a size of arrays in the
prototypes.
* libmisc/copydir.c: Use a size_t for the length of strings.
* libmisc/copydir.c: Cast the return value of malloc().
* libmisc/copydir.c: The size argument of write() is a size_t.
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/pwd2spwd.c: Cast number of days to a long integer.

View File

@ -59,20 +59,20 @@ static struct link_name *links;
static int copy_entry (const char *src, const char *dst,
long int uid, long int gid);
static int copy_dir (const char *src, const char *dst,
const struct stat *statp, const struct timeval mt[2],
const struct stat *statp, const struct timeval mt[],
long int uid, long int gid);
#ifdef S_IFLNK
static int copy_symlink (const char *src, const char *dst,
const struct stat *statp, const struct timeval mt[2],
const struct stat *statp, const struct timeval mt[],
long int uid, long int gid);
#endif
static int copy_hardlink (const char *src, const char *dst,
struct link_name *lp);
static int copy_special (const char *dst,
const struct stat *statp, const struct timeval mt[2],
const struct stat *statp, const struct timeval mt[],
long int uid, long int gid);
static int copy_file (const char *src, const char *dst,
const struct stat *statp, const struct timeval mt[2],
const struct stat *statp, const struct timeval mt[],
long int uid, long int gid);
#ifdef WITH_SELINUX
@ -149,10 +149,10 @@ static void remove_link (struct link_name *ln)
static struct link_name *check_link (const char *name, const struct stat *sb)
{
struct link_name *lp;
int src_len;
int dst_len;
int name_len;
int len;
size_t src_len;
size_t dst_len;
size_t name_len;
size_t len;
for (lp = links; lp; lp = lp->ln_next) {
if ((lp->ln_dev == sb->st_dev) && (lp->ln_ino == sb->st_ino)) {
@ -172,7 +172,7 @@ static struct link_name *check_link (const char *name, const struct stat *sb)
lp->ln_ino = sb->st_ino;
lp->ln_count = sb->st_nlink;
len = name_len - src_len + dst_len + 1;
lp->ln_name = xmalloc (len);
lp->ln_name = (char *) xmalloc (len);
snprintf (lp->ln_name, len, "%s%s", dst_orig, name + src_len);
lp->ln_next = links;
links = lp;
@ -356,7 +356,7 @@ static int copy_entry (const char *src, const char *dst,
* Return 0 on success, -1 on error.
*/
static int copy_dir (const char *src, const char *dst,
const struct stat *statp, const struct timeval mt[2],
const struct stat *statp, const struct timeval mt[],
long int uid, long int gid)
{
int err = 0;
@ -394,7 +394,7 @@ static int copy_dir (const char *src, const char *dst,
* Return 0 on success, -1 on error.
*/
static int copy_symlink (const char *src, const char *dst,
const struct stat *statp, const struct timeval mt[2],
const struct stat *statp, const struct timeval mt[],
long int uid, long int gid)
{
char oldlink[1024];
@ -482,7 +482,7 @@ static int copy_hardlink (const char *src, const char *dst,
* Return 0 on success, -1 on error.
*/
static int copy_special (const char *dst,
const struct stat *statp, const struct timeval mt[2],
const struct stat *statp, const struct timeval mt[],
long int uid, long int gid)
{
int err = 0;
@ -514,14 +514,14 @@ static int copy_special (const char *dst,
* Return 0 on success, -1 on error.
*/
static int copy_file (const char *src, const char *dst,
const struct stat *statp, const struct timeval mt[2],
const struct stat *statp, const struct timeval mt[],
long int uid, long int gid)
{
int err = 0;
int ifd;
int ofd;
char buf[1024];
int cnt;
ssize_t cnt;
ifd = open (src, O_RDONLY);
if (ifd < 0) {
@ -541,7 +541,7 @@ static int copy_file (const char *src, const char *dst,
}
while ((cnt = read (ifd, buf, sizeof buf)) > 0) {
if (write (ofd, buf, cnt) != cnt) {
if (write (ofd, buf, (size_t)cnt) != cnt) {
return -1;
}
}