Warning fixes & impossible-failure improvements

- Silence a couple warnings for less-common builds.
- Use a better impossible-failure idiom than assert(0).
This commit is contained in:
Wayne Davison
2020-07-08 12:19:16 -07:00
parent 7265d96116
commit ab110fc8fb
7 changed files with 20 additions and 7 deletions

View File

@@ -139,7 +139,7 @@ char *client_name(const char *ipaddr)
break;
#endif
default:
assert(0);
NOISY_DEATH("Unknown ai_family value");
}
freeaddrinfo(answer);

View File

@@ -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;
@@ -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);
@@ -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)) {

View File

@@ -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);
}

2
main.c
View File

@@ -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))
{

View File

@@ -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");
}
}

View File

@@ -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)

View File

@@ -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)
@@ -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");
}
}
@@ -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");
}
}
@@ -1103,6 +1103,6 @@ void see_token(char *data, int32 toklen)
break;
#endif
default:
assert(0);
NOISY_DEATH("Unknown do_compression value");
}
}