rewrite assertions with very long messages

This commit is contained in:
Miroslav Lichvar 2016-03-14 15:15:51 +01:00
parent 4acca9b727
commit e7af875b68
2 changed files with 11 additions and 7 deletions

View file

@ -266,9 +266,10 @@ CAM_Initialise(int family)
r.command = htons(i); r.command = htons(i);
command_length = PKL_CommandLength(&r); command_length = PKL_CommandLength(&r);
padding_length = PKL_CommandPaddingLength(&r); padding_length = PKL_CommandPaddingLength(&r);
assert(padding_length <= MAX_PADDING_LENGTH && padding_length <= command_length); if (padding_length > MAX_PADDING_LENGTH || padding_length > command_length ||
assert((command_length >= offsetof(CMD_Request, data) && command_length > sizeof (CMD_Request) ||
command_length <= sizeof (CMD_Request)) || command_length == 0); (command_length && command_length < offsetof(CMD_Request, data)))
assert(0);
} }
for (i = 1; i < N_REPLY_TYPES; i++) { for (i = 1; i < N_REPLY_TYPES; i++) {
@ -279,8 +280,9 @@ CAM_Initialise(int family)
r.status = STT_SUCCESS; r.status = STT_SUCCESS;
r.data.manual_list.n_samples = htonl(MAX_MANUAL_LIST_SAMPLES); r.data.manual_list.n_samples = htonl(MAX_MANUAL_LIST_SAMPLES);
reply_length = PKL_ReplyLength(&r); reply_length = PKL_ReplyLength(&r);
assert((reply_length >= offsetof(CMD_Reply, data) && if ((reply_length && reply_length < offsetof(CMD_Reply, data)) ||
reply_length <= sizeof (CMD_Reply)) || reply_length == 0); reply_length > sizeof (CMD_Reply))
assert(0);
} }
sock_fdu = -1; sock_fdu = -1;

View file

@ -179,7 +179,8 @@ SCH_AddInputFileHandler
/* Don't want to allow the same fd to register a handler more than /* Don't want to allow the same fd to register a handler more than
once without deleting a previous association - this suggests once without deleting a previous association - this suggests
a bug somewhere else in the program. */ a bug somewhere else in the program. */
assert(!FD_ISSET(fd, &read_fds)); if (FD_ISSET(fd, &read_fds))
assert(0);
++n_read_fds; ++n_read_fds;
@ -208,7 +209,8 @@ SCH_RemoveInputFileHandler(int fd)
assert(initialised); assert(initialised);
/* Check that a handler was registered for the fd in question */ /* Check that a handler was registered for the fd in question */
assert(FD_ISSET(fd, &read_fds)); if (!FD_ISSET(fd, &read_fds))
assert(0);
--n_read_fds; --n_read_fds;