Skip to content

Commit

Permalink
Use const pointers in function arguments when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
proski committed Oct 17, 2016
1 parent bc868b9 commit 6fef1e4
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 34 deletions.
2 changes: 1 addition & 1 deletion common/list.c
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion common/list.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion common/log.c
Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion common/log.h
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions common/os_calls.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions common/os_calls.h
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions sesman/access.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions sesman/access.h
Expand Up @@ -35,7 +35,7 @@
*
*/
int DEFAULT_CC
access_login_allowed(char* user);
access_login_allowed(const char *user);

/**
*
Expand All @@ -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
6 changes: 3 additions & 3 deletions sesman/auth.h
Expand Up @@ -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);

/**
*
Expand Down Expand Up @@ -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);

/**
*
Expand All @@ -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
6 changes: 3 additions & 3 deletions sesman/env.c
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions sesman/env.h
Expand Up @@ -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);

/**
*
Expand All @@ -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
5 changes: 3 additions & 2 deletions sesman/session.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions sesman/session.h
Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions sesman/verify_user.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions sesman/verify_user_bsd.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion sesman/verify_user_kerberos.c
Expand Up @@ -396,7 +396,7 @@ k5_kinit(struct k_opts *opts, struct k5_data *k5, struct user_info *u_info)
/******************************************************************************/
/* 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;
Expand Down
2 changes: 1 addition & 1 deletion sesman/verify_user_pam.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion sesman/verify_user_pam_userpass.c
Expand Up @@ -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;
Expand Down

0 comments on commit 6fef1e4

Please sign in to comment.