[SSSD] [PATCH] pam_client: fix casting to const pointer
Lukas Slebodnik
lslebodn at redhat.com
Wed Mar 25 14:03:15 UTC 2015
ehlo,
clang complains about remoing cant qualifier in casting
src/sss_client/pam_sss.c:1461:73:
error: cast from 'int **' to 'const void **' must have all
intermediate pointers const qualified to be safe [-Werror,-Wcast-qual]
pam_get_data(pamh, "pam_sss:password_expired_flag", (const void **) &exp_data);
'int **' should not be casted to 'const void **'
The const must not be removed
There aren't warnings with following castings.
'const int **' - 'const void **'
'int **' - 'void **'
BTW you can see the same kind warning with icc
patch is attached.
LS
-------------- next part --------------
>From afbb4cfb20fc2a6a787ee1df96cb3d71c2271cb7 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 19 Feb 2014 14:20:57 +0100
Subject: [PATCH 2/2] pam_client: fix casting to const pointer
src/sss_client/pam_sss.c:1461:73:
error: cast from 'int **' to 'const void **' must have all
intermediate pointers const qualified to be safe [-Werror,-Wcast-qual]
pam_get_data(pamh, "pam_sss:password_expired_flag", (const void **) &exp_data);
^
---
src/sss_client/pam_sss.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/sss_client/pam_sss.c b/src/sss_client/pam_sss.c
index 6105cac0eb640eef589de26c492059af6378af4d..8c9cec1ce623082a5b142c61fa280c7973ddcebe 100644
--- a/src/sss_client/pam_sss.c
+++ b/src/sss_client/pam_sss.c
@@ -331,7 +331,7 @@ static int do_pam_conversation(pam_handle_t *pamh, const int msg_style,
{
int ret;
int state = SSS_PAM_CONV_STD;
- struct pam_conv *conv;
+ const struct pam_conv *conv;
const struct pam_message *mesg[1];
struct pam_message *pam_msg;
struct pam_response *resp=NULL;
@@ -1457,7 +1457,7 @@ static int get_authtok_for_password_change(pam_handle_t *pamh,
int pam_flags)
{
int ret;
- int *exp_data = NULL;
+ const int *exp_data = NULL;
pam_get_data(pamh, PWEXP_FLAG, (const void **) &exp_data);
/* we query for the old password during PAM_PRELIM_CHECK to make
@@ -1536,7 +1536,7 @@ static int pam_sss(enum sss_cli_command task, pam_handle_t *pamh,
int pam_status;
struct pam_items pi;
uint32_t flags = 0;
- int *exp_data;
+ const int *exp_data;
bool retry = false;
bool quiet_mode = false;
int retries = 0;
@@ -1618,17 +1618,18 @@ static int pam_sss(enum sss_cli_command task, pam_handle_t *pamh,
/* We allow sssd to send the return code PAM_NEW_AUTHTOK_REQD during
* authentication, see sss_cli.h for details */
if (pam_status == PAM_NEW_AUTHTOK_REQD) {
+ int *pw_exp_data;
D(("Authtoken expired, trying to change it"));
- exp_data = malloc(sizeof(int));
- if (exp_data == NULL) {
+ pw_exp_data = malloc(sizeof(int));
+ if (pw_exp_data == NULL) {
D(("malloc failed."));
pam_status = PAM_BUF_ERR;
break;
}
- *exp_data = 1;
+ *pw_exp_data = 1;
- pam_status = pam_set_data(pamh, PWEXP_FLAG, exp_data,
+ pam_status = pam_set_data(pamh, PWEXP_FLAG, pw_exp_data,
free_exp_data);
if (pam_status != PAM_SUCCESS) {
D(("pam_set_data failed."));
--
2.3.3
More information about the sssd-devel
mailing list