Add ssizeof macro that returns ssize_t.

We can use this instead of casting the result of size_t to int.
Also change checks for snprintf() returning <=0 to <0.
This commit is contained in:
Todd C. Miller
2019-06-25 09:45:10 -06:00
parent 81602ad086
commit 9d8f374397
17 changed files with 31 additions and 28 deletions

View File

@@ -1023,7 +1023,7 @@ already_lectured(int unused)
if (ts_secure_dir(def_lecture_status_dir, false, true)) {
len = snprintf(status_file, sizeof(status_file), "%s/%s",
def_lecture_status_dir, user_name);
if (len > 0 && len < (int)sizeof(status_file)) {
if (len > 0 && len < ssizeof(status_file)) {
debug_return_bool(stat(status_file, &sb) == 0);
}
log_warningx(SLOG_SEND_MAIL, N_("lecture status path too long: %s/%s"),
@@ -1045,7 +1045,7 @@ set_lectured(void)
len = snprintf(lecture_status, sizeof(lecture_status), "%s/%s",
def_lecture_status_dir, user_name);
if (len <= 0 || len >= (int)sizeof(lecture_status)) {
if (len < 0 || len >= ssizeof(lecture_status)) {
log_warningx(SLOG_SEND_MAIL, N_("lecture status path too long: %s/%s"),
def_lecture_status_dir, user_name);
goto done;