1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

debug: pass struct debug_class *config to do_one_check_log_size()

Pass a pointer to the struct instead of all struct members individually. No
change in behaviour.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14248

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2020-11-23 15:51:09 +01:00 committed by Jeremy Allison
parent 29cd139a32
commit b7ee361464

View File

@ -1249,11 +1249,10 @@ bool need_to_check_log_size(void)
Check to see if the log has grown to be too big.
**************************************************************************/
static void do_one_check_log_size(off_t maxlog, int *_fd, const char *logfile)
static void do_one_check_log_size(off_t maxlog, struct debug_class *config)
{
char name[strlen(logfile) + 5];
char name[strlen(config->logfile) + 5];
struct stat st;
int fd = *_fd;
int ret;
bool ok;
@ -1261,7 +1260,7 @@ static void do_one_check_log_size(off_t maxlog, int *_fd, const char *logfile)
return;
}
ret = fstat(fd, &st);
ret = fstat(config->fd, &st);
if (ret != 0) {
return;
}
@ -1271,12 +1270,11 @@ static void do_one_check_log_size(off_t maxlog, int *_fd, const char *logfile)
/* reopen_logs_internal() modifies *_fd */
(void)reopen_logs_internal();
fd = *_fd;
if (fd <= 2) {
if (config->fd <= 2) {
return;
}
ret = fstat(fd, &st);
ret = fstat(config->fd, &st);
if (ret != 0) {
return;
}
@ -1284,16 +1282,16 @@ static void do_one_check_log_size(off_t maxlog, int *_fd, const char *logfile)
return;
}
snprintf(name, sizeof(name), "%s.old", logfile);
snprintf(name, sizeof(name), "%s.old", config->logfile);
(void)rename(logfile, name);
(void)rename(config->logfile, name);
ok = reopen_logs_internal();
if (ok) {
return;
}
/* We failed to reopen a log - continue using the old name. */
(void)rename(name, logfile);
(void)rename(name, config->logfile);
}
static void do_check_log_size(off_t maxlog)
@ -1307,9 +1305,7 @@ static void do_check_log_size(off_t maxlog)
if (dbgc_config[i].logfile == NULL) {
continue;
}
do_one_check_log_size(maxlog,
&dbgc_config[i].fd,
dbgc_config[i].logfile);
do_one_check_log_size(maxlog, &dbgc_config[i]);
}
}