[SCM] The rsync repository. - branch master updated

Rsync CVS commit messages rsync-cvs at lists.samba.org
Mon Jul 6 00:32:08 UTC 2020


The branch, master has been updated
       via  e1e4ffe0 Some C99 flexible array changes
       via  1b53b2ff Tweak a comment.
       via  da45cecf Tweak a couple var names.
       via  87b5d233 Setup for 3.2.3dev.
      from  194cee67 Preparing for release of 3.2.2

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e1e4ffe057346de61972b2d995ebc9c720a7d8bd
Author: Wayne Davison <wayne at opencoder.net>
Date:   Sun Jul 5 17:04:37 2020 -0700

    Some C99 flexible array changes
    
    - Use C99 flexible arrays when possible, and fall back on the existing
      fname[1] kluges on older compilers.
    - Avoid static initialization of a flexible array, which is not really
      in the C standard.

commit 1b53b2ff4be476eee15d98d48f68cb1bead0bd77
Author: Wayne Davison <wayne at opencoder.net>
Date:   Sun Jul 5 14:41:53 2020 -0700

    Tweak a comment.

commit da45cecfc8660159c9dd70e1e9dabf8596fdd7e1
Author: Wayne Davison <wayne at opencoder.net>
Date:   Sun Jul 5 09:33:03 2020 -0700

    Tweak a couple var names.

commit 87b5d233e9be3c6abeda48613943f00dd5554bd4
Author: Wayne Davison <wayne at opencoder.net>
Date:   Sun Jul 5 09:26:40 2020 -0700

    Setup for 3.2.3dev.

-----------------------------------------------------------------------

Summary of changes:
 NEWS.md      | 15 +++++++++++++++
 clientname.c |  2 +-
 flist.c      | 13 +++++--------
 options.c    | 18 +++++++++---------
 rsync.h      | 28 +++++++++++++++++++++++++---
 version.h    |  2 +-
 6 files changed, 56 insertions(+), 22 deletions(-)


Changeset truncated at 500 lines:

diff --git a/NEWS.md b/NEWS.md
index 8a104282..faa454cc 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,18 @@
+<a name="3.2.3"></a>
+
+# NEWS for rsync 3.2.3 (UNRELEASED)
+
+## Changes in this version:
+
+### BUG FIXES:
+
+ - None
+
+### ENHANCEMENTS:
+
+ - None
+
+------------------------------------------------------------------------------
 <a name="3.2.2"></a>
 
 # NEWS for rsync 3.2.2 (4 Jul 2020)
diff --git a/clientname.c b/clientname.c
index ef5e4d24..2e36b0ba 100644
--- a/clientname.c
+++ b/clientname.c
@@ -156,7 +156,7 @@ char *client_name(const char *ipaddr)
 }
 
 
-/* Try to read an proxy protocol header (V1 or V2). Returns 1 on success or 0 on failure. */
+/* Try to read a proxy protocol header (V1 or V2). Returns 1 on success or 0 on failure. */
 int read_proxy_protocol_header(int fd)
 {
 	union {
diff --git a/flist.c b/flist.c
index f248e29b..5970ce54 100644
--- a/flist.c
+++ b/flist.c
@@ -1892,7 +1892,7 @@ static void send_implied_dirs(int f, struct file_list *flist, char *fname,
 		memcpy(F_DIR_RELNAMES_P(lastpath_struct), &relname_list, sizeof relname_list);
 	}
 	rnpp = EXPAND_ITEM_LIST(relname_list, relnamecache *, 32);
-	*rnpp = (relnamecache*)new_array(char, sizeof (relnamecache) + len);
+	*rnpp = (relnamecache*)new_array(char, RELNAMECACHE_LEN + len + 1);
 	(*rnpp)->name_type = name_type;
 	strlcpy((*rnpp)->fname, limit+1, len + 1);
 
@@ -2051,8 +2051,7 @@ void send_extra_file_list(int f, int at_least)
 
 		if (need_unsorted_flist) {
 			flist->sorted = new_array(struct file_struct *, flist->used);
-			memcpy(flist->sorted, flist->files,
-			       flist->used * sizeof (struct file_struct*));
+			memcpy(flist->sorted, flist->files, flist->used * PTR_SIZE);
 		} else
 			flist->sorted = flist->files;
 
@@ -2405,8 +2404,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
 	 * send them together in a single file-list. */
 	if (need_unsorted_flist) {
 		flist->sorted = new_array(struct file_struct *, flist->used);
-		memcpy(flist->sorted, flist->files,
-		       flist->used * sizeof (struct file_struct*));
+		memcpy(flist->sorted, flist->files, flist->used * PTR_SIZE);
 	} else
 		flist->sorted = flist->files;
 	flist_sort_and_clean(flist, 0);
@@ -2587,8 +2585,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
 		 * list unsorted for our exchange of index numbers with the
 		 * other side (since their names may not sort the same). */
 		flist->sorted = new_array(struct file_struct *, flist->used);
-		memcpy(flist->sorted, flist->files,
-		       flist->used * sizeof (struct file_struct*));
+		memcpy(flist->sorted, flist->files, flist->used * PTR_SIZE);
 		if (inc_recurse && dir_flist->used > dstart) {
 			static int dir_flist_malloced = 0;
 			if (dir_flist_malloced < dir_flist->malloced) {
@@ -2598,7 +2595,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
 				dir_flist_malloced = dir_flist->malloced;
 			}
 			memcpy(dir_flist->sorted + dstart, dir_flist->files + dstart,
-			       (dir_flist->used - dstart) * sizeof (struct file_struct*));
+			       (dir_flist->used - dstart) * PTR_SIZE);
 			fsort(dir_flist->sorted + dstart, dir_flist->used - dstart);
 		}
 	} else {
diff --git a/options.c b/options.c
index d498e226..956d6e33 100644
--- a/options.c
+++ b/options.c
@@ -586,7 +586,7 @@ static void print_info_flags(enum logcode f)
 	STRUCT_STAT *dumstat;
 	char line_buf[75];
 	int line_len, j;
-	char *capabilities[] = {
+	char *info_flags[] = {
 
 	"*Capabilities",
 
@@ -685,20 +685,20 @@ static void print_info_flags(enum logcode f)
 	};
 
 	for (line_len = 0, j = 0; ; j++) {
-		char *cap = capabilities[j], *next_cap = cap ? capabilities[j+1] : NULL;
-		int cap_len = cap && *cap != '*' ? strlen(cap) : 1000;
-		int need_comma = next_cap && *next_cap != '*' ? 1 : 0;
-		if (line_len && line_len + 1 + cap_len + need_comma >= (int)sizeof line_buf) {
+		char *str = info_flags[j], *next_nfo = str ? info_flags[j+1] : NULL;
+		int str_len = str && *str != '*' ? strlen(str) : 1000;
+		int need_comma = next_nfo && *next_nfo != '*' ? 1 : 0;
+		if (line_len && line_len + 1 + str_len + need_comma >= (int)sizeof line_buf) {
 			rprintf(f, "   %s\n", line_buf);
 			line_len = 0;
 		}
-		if (!cap)
+		if (!str)
 			break;
-		if (*cap == '*') {
-			rprintf(f, "%s:\n", cap+1);
+		if (*str == '*') {
+			rprintf(f, "%s:\n", str+1);
 			continue;
 		}
-		line_len += snprintf(line_buf+line_len, sizeof line_buf - line_len, " %s%s", cap, need_comma ? "," : "");
+		line_len += snprintf(line_buf+line_len, sizeof line_buf - line_len, " %s%s", str, need_comma ? "," : "");
 	}
 }
 
diff --git a/rsync.h b/rsync.h
index 41c4052b..1d6b8179 100644
--- a/rsync.h
+++ b/rsync.h
@@ -732,6 +732,10 @@ struct ht_int64_node {
 # error Character pointers are not 4 or 8 bytes.
 #endif
 
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#define USE_FLEXIBLE_ARRAY 1
+#endif
+
 union file_extras {
 	int32 num;
 	uint32 unum;
@@ -753,7 +757,11 @@ struct file_struct {
 	uint32 len32;		/* Lowest 32 bits of the file's length */
 	uint16 mode;		/* The item's type and permissions */
 	uint16 flags;		/* The FLAG_* bits for this item */
-	const char basename[1];	/* The basename (AKA filename) follows */
+#ifdef USE_FLEXIBLE_ARRAY
+	const char basename[];	/* The basename (AKA filename) follows */
+#else
+	const char basename[1];	/* A kluge that should work like a flexible array */
+#endif
 };
 
 extern int file_extra_cnt;
@@ -766,7 +774,11 @@ extern int gid_ndx;
 extern int acls_ndx;
 extern int xattrs_ndx;
 
+#ifdef USE_FLEXIBLE_ARRAY
+#define FILE_STRUCT_LEN (sizeof (struct file_struct))
+#else
 #define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
+#endif
 #define EXTRA_LEN (sizeof (union file_extras))
 #define DEV_EXTRA_CNT 2
 #define DIRNODE_EXTRA_CNT 3
@@ -1035,9 +1047,19 @@ typedef struct {
 
 typedef struct {
 	char name_type;
-	char fname[1]; /* has variable size */
+#ifdef USE_FLEXIBLE_ARRAY
+	char fname[]; /* has variable size */
+#else
+	char fname[1]; /* A kluge that should work like a flexible array */
+#endif
 } relnamecache;
 
+#ifdef USE_FLEXIBLE_ARRAY
+#define RELNAMECACHE_LEN (sizeof (relnamecache))
+#else
+#define RELNAMECACHE_LEN (offsetof(relnamecache, fname))
+#endif
+
 #include "byteorder.h"
 #include "lib/mdigest.h"
 #include "lib/wildmatch.h"
@@ -1094,7 +1116,7 @@ struct name_num_obj {
 	uchar *saw;
 	int saw_len;
 	int negotiated_num;
-	struct name_num_item list[];
+	struct name_num_item list[8]; /* A big-enough len (we'll get a compile error if it is ever too small) */
 };
 
 #ifndef __cplusplus
diff --git a/version.h b/version.h
index 34fbda49..bf4f8a01 100644
--- a/version.h
+++ b/version.h
@@ -1 +1 @@
-#define RSYNC_VERSION "3.2.2"
+#define RSYNC_VERSION "3.2.3dev"


-- 
The rsync repository.



More information about the rsync-cvs mailing list