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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user