]> granicus.if.org Git - shadow/commitdiff
* libmisc/copydir.c: Do not specify a size of arrays in the
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 13 Jun 2008 20:10:53 +0000 (20:10 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 13 Jun 2008 20:10:53 +0000 (20:10 +0000)
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.

ChangeLog
libmisc/copydir.c

index 8678a011c233efc7bfc93c0ab3e20f35a4846917..3ef6ad794cf65368cea47d5b948146f70bd22a5a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 4d53a5be836c18160caf5325d2042c72d878e7d0..abcea4c19094be353104d48392f6e2d8278e9bbd 100644 (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;
                }
        }