* [PATCH] checkpoint: discard const from struct cred * where appropriate
@ 2009-09-08 21:37 Nathan Lynch
[not found] ` <m3tyzdce33.fsf-V7BBcbaFuwjMbYB6QlFGEg@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Nathan Lynch @ 2009-09-08 21:37 UTC (permalink / raw)
To: Oren Laadan; +Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
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.
Signed-off-by: Nathan Lynch <ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
---
checkpoint/files.c | 4 +++-
checkpoint/process.c | 4 ++--
kernel/cred.c | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/checkpoint/files.c b/checkpoint/files.c
index 204055b..8f90c16 100644
--- a/checkpoint/files.c
+++ b/checkpoint/files.c
@@ -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;
diff --git a/checkpoint/process.c b/checkpoint/process.c
index 40b2580..41566db 100644
--- a/checkpoint/process.c
+++ b/checkpoint/process.c
@@ -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) {
diff --git a/kernel/cred.c b/kernel/cred.c
index 27e02ca..9710cae 100644
--- a/kernel/cred.c
+++ b/kernel/cred.c
@@ -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;
--
1.6.0.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] checkpoint: discard const from struct cred * where appropriate
[not found] ` <m3tyzdce33.fsf-V7BBcbaFuwjMbYB6QlFGEg@public.gmane.org>
@ 2009-09-08 22:09 ` Oren Laadan
[not found] ` <4AA6D600.5080605-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-09-14 15:00 ` Oren Laadan
1 sibling, 1 reply; 4+ messages in thread
From: Oren Laadan @ 2009-09-08 22:09 UTC (permalink / raw)
To: Nathan Lynch; +Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Nathan Lynch wrote:
> 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.
>
> Signed-off-by: Nathan Lynch <ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
Looks good to me.
I vaguely recall that Serge had some issue with this approach ?
Oren.
> ---
> checkpoint/files.c | 4 +++-
> checkpoint/process.c | 4 ++--
> kernel/cred.c | 2 +-
> 3 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/checkpoint/files.c b/checkpoint/files.c
> index 204055b..8f90c16 100644
> --- a/checkpoint/files.c
> +++ b/checkpoint/files.c
> @@ -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;
>
> diff --git a/checkpoint/process.c b/checkpoint/process.c
> index 40b2580..41566db 100644
> --- a/checkpoint/process.c
> +++ b/checkpoint/process.c
> @@ -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) {
> diff --git a/kernel/cred.c b/kernel/cred.c
> index 27e02ca..9710cae 100644
> --- a/kernel/cred.c
> +++ b/kernel/cred.c
> @@ -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;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] checkpoint: discard const from struct cred * where appropriate
[not found] ` <4AA6D600.5080605-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
@ 2009-09-09 1:00 ` Serge E. Hallyn
0 siblings, 0 replies; 4+ messages in thread
From: Serge E. Hallyn @ 2009-09-09 1:00 UTC (permalink / raw)
To: Oren Laadan
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Nathan Lynch
Quoting Oren Laadan (orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org):
>
>
> Nathan Lynch wrote:
> > 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.
> >
> > Signed-off-by: Nathan Lynch <ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
>
> 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.
> Oren.
>
> > ---
> > checkpoint/files.c | 4 +++-
> > checkpoint/process.c | 4 ++--
> > kernel/cred.c | 2 +-
> > 3 files changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/checkpoint/files.c b/checkpoint/files.c
> > index 204055b..8f90c16 100644
> > --- a/checkpoint/files.c
> > +++ b/checkpoint/files.c
> > @@ -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;
> >
> > diff --git a/checkpoint/process.c b/checkpoint/process.c
> > index 40b2580..41566db 100644
> > --- a/checkpoint/process.c
> > +++ b/checkpoint/process.c
> > @@ -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) {
> > diff --git a/kernel/cred.c b/kernel/cred.c
> > index 27e02ca..9710cae 100644
> > --- a/kernel/cred.c
> > +++ b/kernel/cred.c
> > @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] checkpoint: discard const from struct cred * where appropriate
[not found] ` <m3tyzdce33.fsf-V7BBcbaFuwjMbYB6QlFGEg@public.gmane.org>
2009-09-08 22:09 ` Oren Laadan
@ 2009-09-14 15:00 ` Oren Laadan
1 sibling, 0 replies; 4+ messages in thread
From: Oren Laadan @ 2009-09-14 15:00 UTC (permalink / raw)
To: Nathan Lynch; +Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Nathan Lynch wrote:
> 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.
>
> Signed-off-by: Nathan Lynch <ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
Thanks, applied.
> ---
> checkpoint/files.c | 4 +++-
> checkpoint/process.c | 4 ++--
> kernel/cred.c | 2 +-
> 3 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/checkpoint/files.c b/checkpoint/files.c
> index 204055b..8f90c16 100644
> --- a/checkpoint/files.c
> +++ b/checkpoint/files.c
> @@ -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;
>
> diff --git a/checkpoint/process.c b/checkpoint/process.c
> index 40b2580..41566db 100644
> --- a/checkpoint/process.c
> +++ b/checkpoint/process.c
> @@ -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) {
> diff --git a/kernel/cred.c b/kernel/cred.c
> index 27e02ca..9710cae 100644
> --- a/kernel/cred.c
> +++ b/kernel/cred.c
> @@ -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;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-09-14 15:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-08 21:37 [PATCH] checkpoint: discard const from struct cred * where appropriate Nathan Lynch
[not found] ` <m3tyzdce33.fsf-V7BBcbaFuwjMbYB6QlFGEg@public.gmane.org>
2009-09-08 22:09 ` Oren Laadan
[not found] ` <4AA6D600.5080605-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-09-09 1:00 ` Serge E. Hallyn
2009-09-14 15:00 ` Oren Laadan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.