Use const pointers in function arguments when possible

This commit is contained in:
Pavel Roskin 2016-10-16 23:14:06 -07:00
parent bc868b96b1
commit 6fef1e4eb5
18 changed files with 36 additions and 34 deletions

View File

@ -82,7 +82,7 @@ list_add_item(struct list *self, tbus item)
/*****************************************************************************/
tbus APP_CC
list_get_item(struct list *self, int index)
list_get_item(const struct list *self, int index)
{
if (index < 0 || index >= self->count)
{

View File

@ -40,7 +40,7 @@ list_delete(struct list* self);
void APP_CC
list_add_item(struct list* self, tintptr item);
tintptr APP_CC
list_get_item(struct list* self, int index);
list_get_item(const struct list *self, int index);
void APP_CC
list_clear(struct list* self);
int APP_CC

View File

@ -222,7 +222,7 @@ internal_log_end(struct log_config *l_cfg)
* @return
*/
enum logLevels DEFAULT_CC
internal_log_text2level(char *buf)
internal_log_text2level(const char *buf)
{
if (0 == g_strcasecmp(buf, "0") ||
0 == g_strcasecmp(buf, "core"))

View File

@ -113,7 +113,7 @@ internal_log_lvl2str(const enum logLevels lvl, char *str);
*
*/
enum logLevels DEFAULT_CC
internal_log_text2level(char *s);
internal_log_text2level(const char *s);
/**
* A function that init our struct that holds all state and

View File

@ -264,7 +264,7 @@ g_write(const char *format, ...)
/*****************************************************************************/
/* produce a hex dump */
void APP_CC
g_hexdump(char *p, int len)
g_hexdump(const char *p, int len)
{
unsigned char *line;
int i;
@ -1342,7 +1342,7 @@ g_set_nonblock(int fd)
/*****************************************************************************/
/* returns 0 on error */
tintptr APP_CC
g_create_wait_obj(char *name)
g_create_wait_obj(const char *name)
{
#ifdef _WIN32
tintptr obj;

View File

@ -55,7 +55,7 @@ int DEFAULT_CC g_snprintf(char* dest, int len, const char* format, ...) \
printflike(3, 4);
void DEFAULT_CC g_writeln(const char* format, ...) printflike(1, 2);
void DEFAULT_CC g_write(const char* format, ...) printflike(1, 2);
void APP_CC g_hexdump(char* p, int len);
void APP_CC g_hexdump(const char *p, int len);
void APP_CC g_memset(void* ptr, int val, int size);
void APP_CC g_memcpy(void* d_ptr, const void* s_ptr, int size);
int APP_CC g_getchar(void);
@ -88,7 +88,7 @@ int APP_CC g_sck_can_recv(int sck, int millis);
int APP_CC g_sck_select(int sck1, int sck2);
void APP_CC g_write_ip_address(int rcv_sck, char* ip_address, int bytes);
void APP_CC g_sleep(int msecs);
tintptr APP_CC g_create_wait_obj(char* name);
tintptr APP_CC g_create_wait_obj(const char *name);
tintptr APP_CC g_create_wait_obj_from_socket(tintptr socket, int write);
void APP_CC g_delete_wait_obj_from_socket(tintptr wait_obj);
int APP_CC g_set_wait_obj(tintptr obj);

View File

@ -30,7 +30,7 @@ extern struct config_sesman *g_cfg; /* in sesman.c */
/******************************************************************************/
int DEFAULT_CC
access_login_allowed(char *user)
access_login_allowed(const char *user)
{
int gid;
int ok;
@ -79,7 +79,7 @@ access_login_allowed(char *user)
/******************************************************************************/
int DEFAULT_CC
access_login_mng_allowed(char *user)
access_login_mng_allowed(const char *user)
{
int gid;
int ok;

View File

@ -35,7 +35,7 @@
*
*/
int DEFAULT_CC
access_login_allowed(char* user);
access_login_allowed(const char *user);
/**
*
@ -45,6 +45,6 @@ access_login_allowed(char* user);
*
*/
int DEFAULT_CC
access_login_mng_allowed(char* user);
access_login_mng_allowed(const char *user);
#endif

View File

@ -36,7 +36,7 @@
*
*/
long DEFAULT_CC
auth_userpass(char* user, char* pass, int *errorcode);
auth_userpass(const char *user, const char *pass, int *errorcode);
/**
*
@ -94,7 +94,7 @@ auth_set_env(long in_val);
*
*/
int DEFAULT_CC
auth_check_pwd_chg(char* user);
auth_check_pwd_chg(const char *user);
/**
*
@ -104,6 +104,6 @@ auth_check_pwd_chg(char* user);
*
*/
int DEFAULT_CC
auth_change_pwd(char* user, char* newpwd);
auth_change_pwd(const char *user, const char *newpwd);
#endif

View File

@ -34,7 +34,7 @@ extern struct config_sesman *g_cfg; /* in sesman.c */
/******************************************************************************/
int DEFAULT_CC
env_check_password_file(char *filename, char *passwd)
env_check_password_file(const char *filename, const char *passwd)
{
char encryptedPasswd[16];
char key[24];
@ -83,8 +83,8 @@ env_check_password_file(char *filename, char *passwd)
/******************************************************************************/
/* its the responsibility of the caller to free passwd_file */
int DEFAULT_CC
env_set_user(char *username, char **passwd_file, int display,
struct list *env_names, struct list* env_values)
env_set_user(const char *username, char **passwd_file, int display,
const struct list *env_names, const struct list *env_values)
{
int error;
int pw_uid;

View File

@ -38,7 +38,7 @@
*
*/
int DEFAULT_CC
env_check_password_file(char* filename, char* password);
env_check_password_file(const char *filename, const char *password);
/**
*
@ -50,7 +50,7 @@ env_check_password_file(char* filename, char* password);
*
*/
int DEFAULT_CC
env_set_user(char* username, char** passwd_file, int display,
struct list *env_names, struct list* env_values);
env_set_user(const char *username, char **passwd_file, int display,
const struct list *env_names, const struct list *env_values);
#endif

View File

@ -77,7 +77,8 @@ dumpItemsToString(struct list *self, char *outstr, int len)
/******************************************************************************/
struct session_item *DEFAULT_CC
session_get_bydata(char *name, int width, int height, int bpp, int type, char *client_ip)
session_get_bydata(const char *name, int width, int height, int bpp, int type,
const char *client_ip)
{
struct session_chain *tmp;
enum SESMAN_CFG_SESS_POLICY policy = g_cfg->sess.policy;
@ -1016,7 +1017,7 @@ session_get_bypid(int pid)
/******************************************************************************/
struct SCP_DISCONNECTED_SESSION *
session_get_byuser(char *user, int *cnt, unsigned char flags)
session_get_byuser(const char *user, int *cnt, unsigned char flags)
{
struct session_chain *tmp;
struct SCP_DISCONNECTED_SESSION *sess;

View File

@ -91,7 +91,8 @@ struct session_chain
*
*/
struct session_item* DEFAULT_CC
session_get_bydata(char* name, int width, int height, int bpp, int type, char *client_ip);
session_get_bydata(const char *name, int width, int height, int bpp, int type,
const char *client_ip);
#ifndef session_find_item
#define session_find_item(a, b, c, d, e, f) session_get_bydata(a, b, c, d, e, f);
#endif
@ -147,6 +148,6 @@ session_get_bypid(int pid);
*
*/
struct SCP_DISCONNECTED_SESSION*
session_get_byuser(char* user, int* cnt, unsigned char flags);
session_get_byuser(const char *user, int *cnt, unsigned char flags);
#endif

View File

@ -48,7 +48,7 @@ auth_account_disabled(struct spwd *stp);
/******************************************************************************/
/* returns boolean */
long DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode)
auth_userpass(const char *user, const char *pass, int *errorcode)
{
const char *encr;
const char *epass;
@ -125,7 +125,7 @@ auth_set_env(long in_val)
/******************************************************************************/
int DEFAULT_CC
auth_check_pwd_chg(char *user)
auth_check_pwd_chg(const char *user)
{
struct passwd *spw;
struct spwd *stp;
@ -182,7 +182,7 @@ auth_check_pwd_chg(char *user)
}
int DEFAULT_CC
auth_change_pwd(char *user, char *newpwd)
auth_change_pwd(const char *user, const char *newpwd)
{
struct passwd *spw;
struct spwd *stp;

View File

@ -44,7 +44,7 @@ extern struct config_sesman* g_cfg; /* in sesman.c */
/******************************************************************************/
/* returns boolean */
long DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode)
auth_userpass(const char *user, const char *pass, int *errorcode)
{
int ret = auth_userokay(user, NULL, "auth-xrdp", pass);
return ret;
@ -74,13 +74,13 @@ auth_set_env(long in_val)
/******************************************************************************/
int DEFAULT_CC
auth_check_pwd_chg(char* user)
auth_check_pwd_chg(const char *user)
{
return 0;
}
int DEFAULT_CC
auth_change_pwd(char* user, char* newpwd)
auth_change_pwd(const char *user, const char *newpwd)
{
return 0;
}

View File

@ -396,7 +396,7 @@ cleanup:
/******************************************************************************/
/* returns boolean */
int DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode)
auth_userpass(const char *user, const char *pass, int *errorcode)
{
struct k_opts opts;
struct k5_data k5;

View File

@ -102,7 +102,7 @@ get_service_name(char *service_name)
Stores the detailed error code in the errorcode variable*/
long DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode)
auth_userpass(const char *user, const char *pass, int *errorcode)
{
int error;
struct t_auth_info *auth_info;

View File

@ -34,7 +34,7 @@
/******************************************************************************/
/* returns boolean */
int DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode)
auth_userpass(const char *user, const char *pass, int *errorcode)
{
pam_handle_t *pamh;
pam_userpass_t userpass;