Add debug_return_const_str and debug_return_const_ptr for returning

a const string or pointer.  Using const for the normal versions
produces warnings with the Tru64 compiler.
This commit is contained in:
Todd C. Miller
2013-11-17 16:11:39 -07:00
parent bf65cc041e
commit 6c71ad5c15
4 changed files with 25 additions and 9 deletions

View File

@@ -144,27 +144,43 @@
} while (0)
#define debug_return_str(rval) \
do { \
char *sudo_debug_rval = (rval); \
sudo_debug_exit_str(__func__, __FILE__, __LINE__, sudo_debug_subsys, \
sudo_debug_rval); \
return sudo_debug_rval; \
} while (0)
#define debug_return_const_str(rval) \
do { \
const char *sudo_debug_rval = (rval); \
sudo_debug_exit_str(__func__, __FILE__, __LINE__, sudo_debug_subsys, \
sudo_debug_rval); \
return (char *)sudo_debug_rval; \
return sudo_debug_rval; \
} while (0)
#define debug_return_str_masked(rval) \
do { \
const char *sudo_debug_rval = (rval); \
char *sudo_debug_rval = (rval); \
sudo_debug_exit_str_masked(__func__, __FILE__, __LINE__, \
sudo_debug_subsys, sudo_debug_rval); \
return (char *)sudo_debug_rval; \
return sudo_debug_rval; \
} while (0)
#define debug_return_ptr(rval) \
do { \
void *sudo_debug_rval = (rval); \
sudo_debug_exit_ptr(__func__, __FILE__, __LINE__, sudo_debug_subsys, \
sudo_debug_rval); \
return sudo_debug_rval; \
} while (0)
#define debug_return_const_ptr(rval) \
do { \
const void *sudo_debug_rval = (rval); \
sudo_debug_exit_ptr(__func__, __FILE__, __LINE__, sudo_debug_subsys, \
sudo_debug_rval); \
return (void *)sudo_debug_rval; \
return sudo_debug_rval; \
} while (0)
/*

View File

@@ -768,7 +768,7 @@ logfac2str(int n)
for (fac = facilities; fac->name && fac->num != n; fac++)
;
debug_return_str(fac->name);
debug_return_const_str(fac->name);
#else
return "default";
#endif /* LOG_NFACILITIES */
@@ -800,7 +800,7 @@ logpri2str(int n)
for (pri = priorities; pri->name && pri->num != n; pri++)
;
debug_return_str(pri->name);
debug_return_const_str(pri->name);
}
static bool

View File

@@ -1473,7 +1473,7 @@ sudo_krb5_ccname_path(const char *old_ccname)
"ccache %s -> %s", old_ccname, ccname);
/* Credential cache must be a fully-qualified path name. */
debug_return_str(*ccname == '/' ? ccname : NULL);
debug_return_const_str(*ccname == '/' ? ccname : NULL);
}
static bool

View File

@@ -127,7 +127,7 @@ disable_execute(char *const envp[])
envp = nenvp;
#endif /* _PATH_SUDO_NOEXEC */
debug_return_ptr(envp);
debug_return_const_ptr(envp);
}
/*