- Make some char* pointers const.
[rsync/rsync.git] / hlink.c
diff --git a/hlink.c b/hlink.c
index d4808fc..89b9cc7 100644 (file)
--- a/hlink.c
+++ b/hlink.c
@@ -28,7 +28,6 @@ extern int dry_run;
 extern int do_xfers;
 extern int link_dest;
 extern int make_backups;
-extern int flist_extra_ndx;
 extern int remove_source_files;
 extern int stdout_format_has_i;
 extern char *basis_dir[];
@@ -50,10 +49,10 @@ static int hlink_compare(int *int1, int *int2)
        struct idev *i2 = F_IDEV(f2);
 
        if (i1->dev != i2->dev)
-               return (int)(i1->dev > i2->dev ? 1 : -1);
+               return i1->dev > i2->dev ? 1 : -1;
 
        if (i1->ino != i2->ino)
-               return (int)(i1->ino > i2->ino ? 1 : -1);
+               return i1->ino > i2->ino ? 1 : -1;
 
        return f_name_cmp(f1, f2);
 }
@@ -106,7 +105,7 @@ static void link_idev_data(void)
                        file->flags |= FLAG_HLINK_LAST;
                        F_HLIST(file) = hl;
                } else
-                       file->flags &= ~FLAG_HLINK_INFO;
+                       file->flags &= ~FLAG_HLINKED;
        }
 
        if (!to) {
@@ -123,11 +122,9 @@ static void link_idev_data(void)
        the_file_list->hlink_pool = hlink_pool;
        pool_destroy(idev_pool);
 }
-#endif
 
 void init_hard_links(void)
 {
-#ifdef SUPPORT_HARD_LINKS
        int i;
 
        if (hlink_list)
@@ -138,7 +135,7 @@ void init_hard_links(void)
 
        hlink_count = 0;
        for (i = 0; i < the_file_list->count; i++) {
-               if (IS_HLINKED(FPTR(i)))
+               if (F_IS_HLINKED(FPTR(i)))
                        hlink_list[hlink_count++] = i;
        }
 
@@ -150,20 +147,18 @@ void init_hard_links(void)
                hlink_list = NULL;
        } else
                link_idev_data();
-#endif
 }
 
-#ifdef SUPPORT_HARD_LINKS
 static int maybe_hard_link(struct file_struct *file, int ndx,
-                          char *fname, int statret, STRUCT_STAT *st,
-                          char *toname, STRUCT_STAT *to_st,
+                          const char *fname, int statret, STRUCT_STAT *stp,
+                          const char *toname, STRUCT_STAT *to_stp,
                           int itemizing, enum logcode code)
 {
        if (statret == 0) {
-               if (st->st_dev == to_st->st_dev
-                && st->st_ino == to_st->st_ino) {
+               if (stp->st_dev == to_stp->st_dev
+                && stp->st_ino == to_stp->st_ino) {
                        if (itemizing) {
-                               itemize(file, ndx, statret, st,
+                               itemize(file, ndx, statret, stp,
                                        ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS,
                                        0, "");
                        }
@@ -178,16 +173,14 @@ static int maybe_hard_link(struct file_struct *file, int ndx,
                        return -1;
                }
        }
-       return hard_link_one(file, ndx, fname, statret, st, toname,
+       return hard_link_one(file, ndx, fname, statret, stp, toname,
                             0, itemizing, code);
 }
-#endif
 
-int hard_link_check(struct file_struct *file, int ndx, char *fname,
-                   int statret, STRUCT_STAT *st, int itemizing,
+int hard_link_check(struct file_struct *file, int ndx, const char *fname,
+                   int statret, STRUCT_STAT *stp, int itemizing,
                    enum logcode code, int skip)
 {
-#ifdef SUPPORT_HARD_LINKS
        int head;
        struct hlist *hl = F_HLIST(file);
 
@@ -228,7 +221,7 @@ int hard_link_check(struct file_struct *file, int ndx, char *fname,
                                                 || st2.st_ino != st3.st_ino)
                                                        continue;
                                                statret = 1;
-                                               st = &st3;
+                                               stp = &st3;
                                                if (verbose < 2 || !stdout_format_has_i) {
                                                        itemizing = 0;
                                                        code = FNONE;
@@ -238,30 +231,25 @@ int hard_link_check(struct file_struct *file, int ndx, char *fname,
                                        if (!unchanged_file(cmpbuf, file, &st3))
                                                continue;
                                        statret = 1;
-                                       st = &st3;
+                                       stp = &st3;
                                        if (unchanged_attrs(file, &st3))
                                                break;
                                } while (basis_dir[++j] != NULL);
                        }
-                       maybe_hard_link(file, ndx, fname, statret, st,
+                       maybe_hard_link(file, ndx, fname, statret, stp,
                                        toname, &st2, itemizing, code);
-                       if (remove_source_files == 1 && do_xfers) {
-                               char numbuf[4];
-                               SIVAL(numbuf, 0, ndx);
-                               send_msg(MSG_SUCCESS, numbuf, 4);
-                       }
+                       if (remove_source_files == 1 && do_xfers)
+                               send_msg_int(MSG_SUCCESS, ndx);
                        hl->hlindex = FINISHED_LINK;
                } else
                        hl->hlindex = SKIPPED_LINK;
                return 1;
        }
-#endif
        return 0;
 }
 
-#ifdef SUPPORT_HARD_LINKS
-int hard_link_one(struct file_struct *file, int ndx, char *fname,
-                 int statret, STRUCT_STAT *st, char *toname, int terse,
+int hard_link_one(struct file_struct *file, int ndx, const char *fname,
+                 int statret, STRUCT_STAT *stp, const char *toname, int terse,
                  int itemizing, enum logcode code)
 {
        if (do_link(toname, fname)) {
@@ -277,7 +265,7 @@ int hard_link_one(struct file_struct *file, int ndx, char *fname,
        }
 
        if (itemizing) {
-               itemize(file, ndx, statret, st,
+               itemize(file, ndx, statret, stp,
                        ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS, 0,
                        terse ? "" : toname);
        }
@@ -285,13 +273,10 @@ int hard_link_one(struct file_struct *file, int ndx, char *fname,
                rprintf(code, "%s => %s\n", fname, toname);
        return 0;
 }
-#endif
-
 
 void hard_link_cluster(struct file_struct *file, int master, int itemizing,
                       enum logcode code, int dest_used)
 {
-#ifdef SUPPORT_HARD_LINKS
        char hlink1[MAXPATHLEN];
        char *hlink2;
        STRUCT_STAT st1, st2;
@@ -320,12 +305,9 @@ void hard_link_cluster(struct file_struct *file, int master, int itemizing,
                statret = link_stat(hlink2, &st2, 0);
                maybe_hard_link(file, ndx, hlink2, statret, &st2,
                                hlink1, &st1, itemizing, code);
-               if (remove_source_files == 1 && do_xfers) {
-                       char numbuf[4];
-                       SIVAL(numbuf, 0, ndx);
-                       send_msg(MSG_SUCCESS, numbuf, 4);
-               }
+               if (remove_source_files == 1 && do_xfers)
+                       send_msg_int(MSG_SUCCESS, ndx);
                hl->hlindex = FINISHED_LINK;
        } while (!(file->flags & FLAG_HLINK_LAST));
-#endif
 }
+#endif