Skip to content

Commit

Permalink
Warning fixes & impossible-failure improvements
Browse files Browse the repository at this point in the history
- Silence a couple warnings for less-common builds.
- Use a better impossible-failure idiom than assert(0).
  • Loading branch information
WayneD committed Jul 8, 2020
1 parent 7265d96 commit ab110fc
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion clientname.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ char *client_name(const char *ipaddr)
break;
#endif
default:
assert(0);
NOISY_DEATH("Unknown ai_family value");
}
freeaddrinfo(answer);

Expand Down
6 changes: 6 additions & 0 deletions flist.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,9 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
int extra_len = file_extra_cnt * EXTRA_LEN;
int first_hlink_ndx = -1;
int64 file_length;
#ifdef CAN_SET_NSEC
uint32 modtime_nsec;
#endif
const char *basename;
struct file_struct *file;
alloc_pool_t *pool;
Expand Down Expand Up @@ -767,7 +769,9 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start];
file_length = F_LENGTH(first);
modtime = first->modtime;
#ifdef CAN_SET_NSEC
modtime_nsec = F_MOD_NSEC_or_0(first);
#endif
mode = first->mode;
if (atimes_ndx && !S_ISDIR(mode))
atime = F_ATIME(first);
Expand Down Expand Up @@ -803,10 +807,12 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
} else
modtime = read_int(f);
}
#ifdef CAN_SET_NSEC
if (xflags & XMIT_MOD_NSEC)
modtime_nsec = read_varint(f);
else
modtime_nsec = 0;
#endif
if (!(xflags & XMIT_SAME_MODE))
mode = from_wire_mode(read_int(f));
if (atimes_ndx && !S_ISDIR(mode) && !(xflags & XMIT_SAME_ATIME)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/sysacls.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ int sys_acl_free_acl(SMB_ACL_T acl_d)
/* calls if it isn't there. */

#ifdef __TANDEM
inline do_acl(const char *path_p, int cmd, int nentries, struct acl *aclbufp)
inline int do_acl(const char *path_p, int cmd, int nentries, struct acl *aclbufp)
{
return acl((char*)path_p, cmd, nentries, aclbufp);
}
Expand Down
2 changes: 2 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1555,11 +1555,13 @@ static void sigusr2_handler(UNUSED(int val))
_exit(0);
}

#if defined SIGINFO || defined SIGVTALRM
static void siginfo_handler(UNUSED(int val))
{
if (!am_server && !INFO_GTE(PROGRESS, 1))
want_progress_now = True;
}
#endif

void remember_children(UNUSED(int val))
{
Expand Down
2 changes: 1 addition & 1 deletion options.c
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ char *alt_dest_opt(int type)
case LINK_DEST:
return "--link-dest";
default:
assert(0);
NOISY_DEATH("Unknown alt_dest_opt type");
}
}

Expand Down
5 changes: 5 additions & 0 deletions rsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -1435,3 +1435,8 @@ char *getpass(const char *prompt);
#ifdef MAINTAINER_MODE
const char *get_panic_action(void);
#endif

#define NOISY_DEATH(msg) do { \
fprintf(stderr, "%s in %s at line %d\n", msg, __FILE__, __LINE__); \
exit_cleanup(RERR_UNSUPPORTED); \
} while (0)
8 changes: 4 additions & 4 deletions token.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void init_compression_level(void)
break;
#endif
default: /* paranoia to prevent missing case values */
assert(0);
NOISY_DEATH("Unknown do_compression value");
}

if (do_compression_level == CLVL_NOT_SPECIFIED)
Expand Down Expand Up @@ -1049,7 +1049,7 @@ void send_token(int f, int32 token, struct map_struct *buf, OFF_T offset,
break;
#endif
default:
assert(0);
NOISY_DEATH("Unknown do_compression value");
}
}

Expand All @@ -1076,7 +1076,7 @@ int32 recv_token(int f, char **data)
return recv_compressed_token(f, data);
#endif
default:
assert(0);
NOISY_DEATH("Unknown do_compression value");
}
}

Expand All @@ -1103,6 +1103,6 @@ void see_token(char *data, int32 toklen)
break;
#endif
default:
assert(0);
NOISY_DEATH("Unknown do_compression value");
}
}

0 comments on commit ab110fc

Please sign in to comment.