From 668475ae474524a8023515d794db22fa8d2f540d Mon Sep 17 00:00:00 2001 From: Simon Pichugin Date: Jul 17 2020 08:33:12 +0000 Subject: Issue 50984 - Fix disk_mon_check_diskspace types Description: Function parameters are inconsistence. Documentation states that threshold should be from 0 to 2^63 - 1 so we can use uint64_t for that. https://pagure.io/389-ds-base/issue/50984 Reviewed by: firstyear (Thanks!) --- diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index 772b496..0c5585e 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -345,8 +345,8 @@ disk_mon_check_diskspace(char **dirs, uint64_t threshold, uint64_t *disk_space) uint64_t freeBytes = 0; uint64_t blockSize = 0; char *worst_dir = NULL; - int hit_threshold = 0; - int i = 0; + int32_t hit_threshold = 0; + int32_t i = 0; for (i = 0; dirs && dirs[i]; i++) { if (statvfs(dirs[i], &buf) != -1) { @@ -396,7 +396,7 @@ disk_monitoring_thread(void *nothing __attribute__((unused))) char *dirstr = NULL; uint64_t previous_mark = 0; uint64_t disk_space = 0; - int64_t threshold = 0; + uint64_t threshold = 0; uint64_t halfway = 0; time_t start = 0; time_t now = 0; diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index 97af7bb..7d5374c 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -2031,7 +2031,7 @@ config_set_disk_threshold(const char *attrname, char *value, char *errorbuf, int if (apply) { CFG_LOCK_WRITE(slapdFrontendConfig); - slapdFrontendConfig->disk_threshold = threshold; + slapdFrontendConfig->disk_threshold = (uint64_t)threshold; CFG_UNLOCK_WRITE(slapdFrontendConfig); } @@ -5164,11 +5164,11 @@ config_get_disk_grace_period() return retVal; } -PRInt64 +uint64_t config_get_disk_threshold() { slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - PRInt64 retVal; + uint64_t retVal; CFG_LOCK_READ(slapdFrontendConfig); retVal = slapdFrontendConfig->disk_threshold; diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index 9e5219c..694375b 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -894,7 +894,7 @@ main(int argc, char **argv) char **dirs = NULL; char *dirstr = NULL; uint64_t disk_space = 0; - int64_t threshold = 0; + uint64_t threshold = 0; uint64_t halfway = 0; threshold = config_get_disk_threshold(); halfway = threshold / 2; diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index 41308f1..3acc24f 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -545,7 +545,7 @@ void config_set_auditfaillog_enabled(int value); int config_get_accesslog_logging_enabled(void); int config_get_disk_monitoring(void); int config_get_disk_threshold_readonly(void); -PRInt64 config_get_disk_threshold(void); +uint64_t config_get_disk_threshold(void); int config_get_disk_grace_period(void); int config_get_disk_logging_critical(void); int config_get_ndn_cache_count(void);