From 7e4b6b7bc47b8ac00fa295ed60e6e13e28fd1a8a Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Mon, 3 Sep 2007 04:19:11 +0000 Subject: [PATCH] Use new0() function instead of new() followed by memset(). --- exclude.c | 3 +-- fileio.c | 3 +-- flist.c | 16 +++++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/exclude.c b/exclude.c index 96469ab3..a2618600 100644 --- a/exclude.c +++ b/exclude.c @@ -144,9 +144,8 @@ static void add_rule(struct filter_list_struct *listp, const char *pat, } } - if (!(ret = new(struct filter_struct))) + if (!(ret = new0(struct filter_struct))) out_of_memory("add_rule"); - memset(ret, 0, sizeof ret[0]); if (!(mflags & (MATCHFLG_ABS_PATH | MATCHFLG_MERGE_FILE)) && ((xflags & (XFLG_ANCHORED2ABS|XFLG_ABS_IF_SLASH) && *pat == '/') diff --git a/fileio.c b/fileio.c index d97cdac7..bf640e20 100644 --- a/fileio.c +++ b/fileio.c @@ -159,13 +159,12 @@ struct map_struct *map_file(int fd, OFF_T len, int32 read_size, { struct map_struct *map; - if (!(map = new(struct map_struct))) + if (!(map = new0(struct map_struct))) out_of_memory("map_file"); if (blk_size && (read_size % blk_size)) read_size += blk_size - (read_size % blk_size); - memset(map, 0, sizeof map[0]); map->fd = fd; map->file_size = len; map->def_window_size = read_size; diff --git a/flist.c b/flist.c index c7607f03..701fe3bc 100644 --- a/flist.c +++ b/flist.c @@ -89,6 +89,18 @@ int flist_cnt = 0; /* how many (non-tmp) file list objects exist */ int file_total = 0; /* total of all active items over all file-lists */ int flist_eof = 0; /* all the file-lists are now known */ +/* Starting from protocol version 26, we always use 64-bit ino_t and dev_t + * internally, even if this platform does not allow files to have 64-bit inums. + * The only exception is if we're on a platform with no 64-bit type at all. + * + * Because we use read_longint() to get these off the wire, if you transfer + * devices or (for protocols < 30) hardlinks with dev or inum > 2**32 to a + * machine with no 64-bit types then you will get an overflow error. + * + * Note that if you transfer devices from a 64-bit-devt machine (say, Solaris) + * to a 32-bit-devt machine (say, Linux-2.2/x86) then the device numbers will + * be truncated. But it's a kind of silly thing to do anyhow. */ + /* The tmp_* vars are used as a cache area by make_file() to store data * that the sender doesn't need to remember in its file list. The data * will survive just long enough to be used by send_file_entry(). */ @@ -2164,12 +2176,10 @@ struct file_list *flist_new(int flags, char *msg) { struct file_list *flist; - flist = new(struct file_list); + flist = new0(struct file_list); if (!flist) out_of_memory(msg); - memset(flist, 0, sizeof flist[0]); - if (flags & FLIST_TEMP) { if (!(flist->file_pool = pool_create(SMALL_EXTENT, 0, out_of_memory, POOL_INTERN))) -- 2.34.1