checkpoint: discard const from struct cred * where appropriate
PATCH 1/1 checkpoint: discard const from struct cred * where appropriate
Building the checkpoint tree results in enough build noise that it's getting easy to miss new warnings added during development:
kernel/cred.c:737: warning: passing argument 2 of 'checkpoint_capabilities' discards qualifiers from pointer target type checkpoint/process.c:146: warning: assignment discards qualifiers from pointer target type checkpoint/process.c:147: warning: assignment discards qualifiers from pointer target type checkpoint/files.c:154: warning: passing argument 2 of 'checkpoint_obj' discards qualifiers from pointer target type
The objhash code would require significant modification to properly handle const objects, and only struct cred * is causing this kind of warning, so just insert casts or drop const where it makes sense.
--- checkpoint/files.c | 4 +++- checkpoint/process.c | 4 ++-- kernel/cred.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)
checkpoint/files.c +3 -1
@@ -146,12 +146,14 @@ static int scan_fds(struct files_struct *files, int **fdtable)int checkpoint_file_common (struct ckpt_ctx *ctx,struct file *file,struct ckpt_hdr_file *h) { +struct cred *f_cred = (struct cred *)file->f_cred; + h->f_flags = file->f_flags; h->f_mode = file->f_mode; h->f_pos = file->f_pos; h->f_version = file->f_version; - h->f_credref =checkpoint_obj (ctx, file->f_cred,CKPT_OBJ_CRED ); + h->f_credref =checkpoint_obj (ctx, f_cred,CKPT_OBJ_CRED );if (h->f_credref <0 )return h->f_credref;
checkpoint/process.c +2 -2
@@ -143,8 +143,8 @@ static int checkpoint_task_creds(struct ckpt_ctx *ctx, struct task_struct *t)struct ckpt_hdr_task_creds *h;int ret; - rcred =get_cred (t->real_cred); - ecred =get_cred (t->cred); + rcred = (struct cred *)get_cred (t->real_cred); + ecred = (struct cred *)get_cred (t->cred); realcred_ref =checkpoint_obj (ctx, rcred,CKPT_OBJ_CRED );if (realcred_ref <0 ) {
kernel/cred.c +1 -1
@@ -706,7 +706,7 @@ int cred_setfsgid(struct cred *new, gid_t gid, gid_t *old_fsgid) }#ifdef CONFIG_CHECKPOINT -static int do_checkpoint_cred (struct ckpt_ctx *ctx,const struct cred *cred) +static int do_checkpoint_cred (struct ckpt_ctx *ctx,struct cred *cred) {int ret;int groupinfo_ref, user_ref;
Signature · 1 line
1.6.0.6
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 8 lines · Nathan Lynch
Building the checkpoint tree results in enough build noise that it's getting easy to miss new warnings added during development:
kernel/cred.c:737: warning: passing argument 2 of 'checkpoint_capabilities' discards qualifiers from pointer target typecheckpoint/process.c:146: warning: assignment discards qualifiers from pointer target typecheckpoint/process.c:147: warning: assignment discards qualifiers from pointer target typecheckpoint/files.c:154: warning: passing argument 2 of 'checkpoint_obj' discards qualifiers from pointer target type
Quoted 5 lines
The objhash code would require significant modification to properly handle const objects, and only struct cred * is causing this kind of warning, so just insert casts or drop const where it makes sense.
Signed-off-by Nathan Lynch <[email protected]>
Looks good to me.
I vaguely recall that Serge had some issue with this approach ?
Oren.
Quoted 54 lines
--- checkpoint/files.c | 4 +++- checkpoint/process.c | 4 ++-- kernel/cred.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)checkpoint/files.c +3
-1@@ -146,12 +146,14 @@ static int scan_fds(struct files_struct *files, int **fdtable)int checkpoint_file_common (struct ckpt_ctx *ctx,struct file *file,struct ckpt_hdr_file *h) { +struct cred *f_cred = (struct cred *)file->f_cred; + h->f_flags = file->f_flags; h->f_mode = file->f_mode; h->f_pos = file->f_pos; h->f_version = file->f_version; - h->f_credref =checkpoint_obj (ctx, file->f_cred,CKPT_OBJ_CRED ); + h->f_credref =checkpoint_obj (ctx, f_cred,CKPT_OBJ_CRED );if (h->f_credref <0 )return h->f_credref;checkpoint/process.c +2
-2@@ -143,8 +143,8 @@ static int checkpoint_task_creds(struct ckpt_ctx *ctx, struct task_struct *t)struct ckpt_hdr_task_creds *h;int ret; - rcred =get_cred (t->real_cred); - ecred =get_cred (t->cred); + rcred = (struct cred *)get_cred (t->real_cred); + ecred = (struct cred *)get_cred (t->cred); realcred_ref =checkpoint_obj (ctx, rcred,CKPT_OBJ_CRED );if (realcred_ref <0 ) {kernel/cred.c +1
-1@@ -706,7 +706,7 @@ int cred_setfsgid(struct cred *new, gid_t gid, gid_t *old_fsgid) }#ifdef CONFIG_CHECKPOINT -static int do_checkpoint_cred (struct ckpt_ctx *ctx,const struct cred *cred) +static int do_checkpoint_cred (struct ckpt_ctx *ctx,struct cred *cred) {int ret;int groupinfo_ref, user_ref;
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 15 lines · Oren Laadan
Quoted 12 lines · Nathan Lynch
Building the checkpoint tree results in enough build noise that it's getting easy to miss new warnings added during development:
kernel/cred.c:737: warning: passing argument 2 of 'checkpoint_capabilities' discards qualifiers from pointer target typecheckpoint/process.c:146: warning: assignment discards qualifiers from pointer target typecheckpoint/process.c:147: warning: assignment discards qualifiers from pointer target typecheckpoint/files.c:154: warning: passing argument 2 of 'checkpoint_obj' discards qualifiers from pointer target typeThe objhash code would require significant modification to properly handle const objects, and only struct cred * is causing this kind of warning, so just insert casts or drop const where it makes sense.
Quoted 5 lines
Quoted 1 line
Signed-off-by Nathan Lynch <[email protected]>Looks good to me.
I vaguely recall that Serge had some issue with this approach ?
I don't. This might be the best solution, and we do need to shut those warnings up. David Howells might have a problem with it though, so he should be cc:d.
Quoted 60 lines
Oren.
Quoted 46 lines
--- checkpoint/files.c | 4 +++- checkpoint/process.c | 4 ++-- kernel/cred.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)checkpoint/files.c +3
-1@@ -146,12 +146,14 @@ static int scan_fds(struct files_struct *files, int **fdtable)int checkpoint_file_common (struct ckpt_ctx *ctx,struct file *file,struct ckpt_hdr_file *h) { +struct cred *f_cred = (struct cred *)file->f_cred; + h->f_flags = file->f_flags; h->f_mode = file->f_mode; h->f_pos = file->f_pos; h->f_version = file->f_version; - h->f_credref =checkpoint_obj (ctx, file->f_cred,CKPT_OBJ_CRED ); + h->f_credref =checkpoint_obj (ctx, f_cred,CKPT_OBJ_CRED );if (h->f_credref <0 )return h->f_credref;checkpoint/process.c +2
-2@@ -143,8 +143,8 @@ static int checkpoint_task_creds(struct ckpt_ctx *ctx, struct task_struct *t)struct ckpt_hdr_task_creds *h;int ret; - rcred =get_cred (t->real_cred); - ecred =get_cred (t->cred); + rcred = (struct cred *)get_cred (t->real_cred); + ecred = (struct cred *)get_cred (t->cred); realcred_ref =checkpoint_obj (ctx, rcred,CKPT_OBJ_CRED );if (realcred_ref <0 ) {kernel/cred.c +0
-0kernel/cred.c int cred_setfsgid(struct cred *new, gid_t gid, gid_t *old_fsgid) · line 712
Quoted 8 lines
kernel/cred.c +1
-1@@ -706,7 +706,7 @@ int cred_setfsgid(struct cred *new, gid_t gid, gid_t *old_fsgid) }#ifdef CONFIG_CHECKPOINT -static int do_checkpoint_cred (struct ckpt_ctx *ctx,const struct cred *cred) +static int do_checkpoint_cred (struct ckpt_ctx *ctx,struct cred *cred) {int ret;int groupinfo_ref, user_ref;_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Oren Laadan
AppliedQuoted 8 lines · Nathan Lynch
Building the checkpoint tree results in enough build noise that it's getting easy to miss new warnings added during development:
kernel/cred.c:737: warning: passing argument 2 of 'checkpoint_capabilities' discards qualifiers from pointer target typecheckpoint/process.c:146: warning: assignment discards qualifiers from pointer target typecheckpoint/process.c:147: warning: assignment discards qualifiers from pointer target typecheckpoint/files.c:154: warning: passing argument 2 of 'checkpoint_obj' discards qualifiers from pointer target type
Quoted 5 lines
The objhash code would require significant modification to properly handle const objects, and only struct cred * is causing this kind of warning, so just insert casts or drop const where it makes sense.
Signed-off-by Nathan Lynch <[email protected]>
Thanks, applied.
Quoted 54 lines
--- checkpoint/files.c | 4 +++- checkpoint/process.c | 4 ++-- kernel/cred.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)checkpoint/files.c +3
-1@@ -146,12 +146,14 @@ static int scan_fds(struct files_struct *files, int **fdtable)int checkpoint_file_common (struct ckpt_ctx *ctx,struct file *file,struct ckpt_hdr_file *h) { +struct cred *f_cred = (struct cred *)file->f_cred; + h->f_flags = file->f_flags; h->f_mode = file->f_mode; h->f_pos = file->f_pos; h->f_version = file->f_version; - h->f_credref =checkpoint_obj (ctx, file->f_cred,CKPT_OBJ_CRED ); + h->f_credref =checkpoint_obj (ctx, f_cred,CKPT_OBJ_CRED );if (h->f_credref <0 )return h->f_credref;checkpoint/process.c +2
-2@@ -143,8 +143,8 @@ static int checkpoint_task_creds(struct ckpt_ctx *ctx, struct task_struct *t)struct ckpt_hdr_task_creds *h;int ret; - rcred =get_cred (t->real_cred); - ecred =get_cred (t->cred); + rcred = (struct cred *)get_cred (t->real_cred); + ecred = (struct cred *)get_cred (t->cred); realcred_ref =checkpoint_obj (ctx, rcred,CKPT_OBJ_CRED );if (realcred_ref <0 ) {kernel/cred.c +1
-1@@ -706,7 +706,7 @@ int cred_setfsgid(struct cred *new, gid_t gid, gid_t *old_fsgid) }#ifdef CONFIG_CHECKPOINT -static int do_checkpoint_cred (struct ckpt_ctx *ctx,const struct cred *cred) +static int do_checkpoint_cred (struct ckpt_ctx *ctx,struct cred *cred) {int ret;int groupinfo_ref, user_ref;