Skip to content

Commit

Permalink
Removal of NULL verification of strrchr return
Browse files Browse the repository at this point in the history
Since the macros always have underscore in them, the NULL verification is
not needed.
  • Loading branch information
m3g4d1v3r committed Nov 8, 2024
1 parent e3f4b99 commit c0fb2e4
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/prival.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,19 @@ const char *
stumpless_get_priority_string( int prival ) {
const char *facility;
const char *severity;
const char *aux;

size_t priority_string_size;
char* priority_string;

facility = stumpless_get_facility_string( get_facility( prival ) );
severity = stumpless_get_severity_string( get_severity( prival ) );

aux = facility;
facility = strrchr(facility, '_');
if (facility == NULL)
facility = aux;
else
facility++; // inc by 1 to skip '_'

aux = severity;
severity = strrchr(severity, '_');
if (severity == NULL)
severity = aux;
else
severity++; // inc by 1 to skip '_'

// inc by 1 to skip '_'
facility++;
severity++;

size_t len_facility = strlen(facility);
size_t len_severity = strlen(severity);
Expand Down

0 comments on commit c0fb2e4

Please sign in to comment.