Skip to content

Commit

Permalink
vasqLoggerCreate now sets *logger to NULL upon error; vasqLoggerCreat…
Browse files Browse the repository at this point in the history
…e no longer calls vasqSetLoggerLevel; vasqSetLoggerLevel no longer emits a log message; changed version to 6.0.6
  • Loading branch information
nickeldan committed Dec 15, 2022
1 parent 0027617 commit fe011c1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Vanilla Squad
=============

:Author: Daniel Walker
:Version: 6.0.5
:Date: 2022-09-01
:Version: 6.0.6
:Date: 2022-12-14

Overview
========
Expand Down
4 changes: 4 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
6.0.6:
- vasqLoggerCreate now sets *logger to NULL upon error.
- vasqSetLoggerLevel no longer emits a logging message.

6.0.5:
- make.mk now creates any necessary directories.
- Added an include guard to make.mk.
Expand Down
7 changes: 0 additions & 7 deletions include/vasq/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@
#define VASQ_LL_PROCESS VASQ_LL_DEBUG
#endif

/**
* @brief The log level which displays the setting of a logger's log level.
*/
#ifndef VASQ_LL_LEVEL_CHANGE
#define VASQ_LL_LEVEL_CHANGE VASQ_LL_DEBUG
#endif

/**
* @brief Causes the PLACEHOLDER() macro to generate an error when used even if DEBUG or
* VASQ_ALLOW_PLACEHOLDER are defined.
Expand Down
2 changes: 1 addition & 1 deletion include/vasq/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* @brief Current version of the library.
*/
#define VASQ_VERSION "6.0.5"
#define VASQ_VERSION "6.0.6"

#ifndef NO_OP
#define NO_OP ((void)0)
Expand Down
12 changes: 5 additions & 7 deletions source/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ vasqLoggerCreate(int fd, vasqLogLevel_t level, const char *format, const vasqLog

default:
free(*logger);
*logger = NULL;
errno = local_errno;
return VASQ_RET_DUP_FAIL;
}
Expand All @@ -268,7 +269,7 @@ vasqLoggerCreate(int fd, vasqLogLevel_t level, const char *format, const vasqLog
(*logger)->processor = options->processor;
(*logger)->user = options->user;
(*logger)->hex_dump_info = !!(options->flags & VASQ_LOGGER_FLAG_HEX_DUMP_INFO);
vasqSetLoggerLevel(*logger, level);
(*logger)->level = level;

if (options->flags & VASQ_LOGGER_FLAG_CLOEXEC) {
int flags;
Expand All @@ -277,6 +278,7 @@ vasqLoggerCreate(int fd, vasqLogLevel_t level, const char *format, const vasqLog
if (flags == -1 || fcntl(new_fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
local_errno = errno;
vasqLoggerFree(*logger);
*logger = NULL;
errno = local_errno;
return VASQ_RET_FCNTL_FAIL;
}
Expand Down Expand Up @@ -326,13 +328,9 @@ vasqLoggerLevel(const vasqLogger *logger)
void
vasqSetLoggerLevel(vasqLogger *logger, vasqLogLevel_t level)
{
if (!logger) {
return;
if (logger) {
logger->level = level;
}

logger->level = level;
vasqLogStatement(logger, VASQ_LL_LEVEL_CHANGE, VASQ_CONTEXT_PARAMS, "Log level set to %s",
logLevelName(level));
}

void
Expand Down
5 changes: 2 additions & 3 deletions source/safe_snprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ vasqSafeVsnprintf(char *buffer, size_t size, const char *format, va_list args)
{
char *start = buffer;

if (!buffer || size == 0 || !format) {
if (!buffer || size-- == 0 || !format) { // The -- is to leave space for the null terminator.
return -1;
}

for (size--; *format && size > 0; format++) { // The -- is to leave space for the null terminator.
for (; *format && size > 0; format++) {
char c = *format;

if (c == '%') {
Expand Down Expand Up @@ -271,7 +271,6 @@ vasqSafeVsnprintf(char *buffer, size_t size, const char *format, va_list args)
}

done:

*buffer = '\0';
return buffer - start;
}
Expand Down

0 comments on commit fe011c1

Please sign in to comment.