Skip to content

Commit

Permalink
Fix const warning and log formatting
Browse files Browse the repository at this point in the history
GetConfigOption returns a const char * and it was being handled without casting,
since removal of pstrdup in the last version of the patch. Fix this by declaring
the variable const char * per other examples in postgres.

Additionally account for typical use of whitespace at the end of
`log_line_prefix` variables by not adding an extra whitespace character between
the old value and the audit tag.
  • Loading branch information
mpalmi committed May 17, 2018
1 parent 4dbe435 commit f0bb8cc
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions set_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,11 @@ set_user(PG_FUNCTION_ARGS)

if (NewUser_is_superuser && Block_LS)
{
char *new_log_prefix = NULL;
char *old_log_prefix = NULL;


old_log_prefix = GetConfigOption("log_line_prefix", true, false);
const char *old_log_prefix = GetConfigOption("log_line_prefix", true, false);
char *new_log_prefix = NULL;

if (old_log_prefix)
new_log_prefix = psprintf("%s %s: ", old_log_prefix, SU_AuditTag);
new_log_prefix = psprintf("%s%s: ", old_log_prefix, SU_AuditTag);
else
new_log_prefix = pstrdup(SU_AuditTag);

Expand Down

0 comments on commit f0bb8cc

Please sign in to comment.