From 9921e8f4a70c12c98b12a281553cf04bb7d83469 Mon Sep 17 00:00:00 2001 From: Ankaa19 Date: Thu, 5 Dec 2024 00:10:44 +0100 Subject: [PATCH] used VALIDATE_ARG_NOT_NULL_INT_RETURN in functions --- src/facility.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/facility.c b/src/facility.c index ac673c0b..7da91073 100644 --- a/src/facility.c +++ b/src/facility.c @@ -20,6 +20,7 @@ #include #include #include "private/facility.h" +#include #include "private/strhelper.h" #include "private/error.h" @@ -39,23 +40,18 @@ stumpless_get_facility_string( enum stumpless_facility facility ) { enum stumpless_facility stumpless_get_facility_enum( const char *facility_string ) { - if (!facility_string) { - raise_argument_empty( "facility_string is NULL" ); - return -1; - } + VALIDATE_ARG_NOT_NULL_INT_RETURN(facility_string); + enum stumpless_facility facility = stumpless_get_facility_enum_from_buffer(facility_string, strlen(facility_string)); if (facility == -1) { - raise_invalid_facility(-1); + raise_invalid_facility(STUMPLESS_INVALID_ENCODING); } return facility; } enum stumpless_facility stumpless_get_facility_enum_from_buffer(const char *facility_buffer, size_t facility_buffer_length) { - if (!facility_buffer) { - raise_argument_empty( "facility_buffer is NULL" ); - return -1; - } + VALIDATE_ARG_NOT_NULL_INT_RETURN(facility_buffer); size_t facility_bound; size_t i; @@ -79,7 +75,7 @@ stumpless_get_facility_enum_from_buffer(const char *facility_buffer, size_t faci if( strncasecmp_custom( facility_buffer, "AUTHPRIV", facility_buffer_length ) == 0 ) { return STUMPLESS_FACILITY_AUTH2_VALUE; } - raise_invalid_facility(-1); + raise_invalid_facility(STUMPLESS_INVALID_FACILITY); return -1; } @@ -93,4 +89,4 @@ get_facility( int prival ) { int facility_is_invalid( int facility ) { return facility < 0 || facility > ( 23 << 3 ) || facility % 8 != 0; -} \ No newline at end of file +}