On Thu, May 14, 2009 at 01:34:26PM -0400, Steve Olivieri wrote:
> Hi,
>
> It's not a magic number. Four is the length of the string "Uid:". You
> could replace it with strlen("Uid:"), but would that really be better?
>
I would say so. It would make it obviously clear that it is for Uid:.
Also, if you notice, the sscanf is doing a buf+5, why is 5 the correct
place, and it just makes it much clearer.
> - Steve
>
> > On Wed, May 13, 2009 at 01:12:39PM +0900, Masayuki Igawa wrote:
> >> Hi,
> >>
> >> There is the problem that cgrulesengd cannot get Gid from
> >> /proc/PID/status,
> >> because the function breaks just after getting Uid data:
> >>
> >> $ cat /proc/$$/status
> >> [snip]
> >> Uid: 500 500 500 500
> >> Gid: 500 500 500 500
> >> [snip]
> >> $
> >>
> >> This patch fixes this problem.
> >>
> >> Thanks.
> >> Masayuki Igawa
> >>
> >> Signed-off-by: Masayuki Igawa <[email protected]>
> >> ---
> >> src/daemon/cgrulesengd.c | 2 --
> >> 1 files changed, 0 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/src/daemon/cgrulesengd.c b/src/daemon/cgrulesengd.c
> >> index 07d4a5d..595c321 100644
> >> --- a/src/daemon/cgrulesengd.c
> >> +++ b/src/daemon/cgrulesengd.c
> >> @@ -168,11 +168,9 @@ static int cgre_get_euid_egid_from_status(pid_t
> >> pid, uid_t *euid, gid_t *egid)
> >> if (!strncmp(buf, "Uid:", 4)) {
> >> sscanf((buf + 5), "%d%d%d%d", &ruid, euid,
> >> &suid, &fsuid);
> >> - break;
> >> } else if (!strncmp(buf, "Gid:", 4)) {
> >
> > while we are at it. I see another cleanup possible here. 4 is a magic
> > number. Can we have a macro replacing it?
> >
> > thanks,
> > --
> > regards,
> > Dhaval
> >
> > ------------------------------------------------------------------------------
> > The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
> > production scanning environment may not be a perfect world - but thanks to
> > Kodak, there's a perfect scanner to get the job done! With the NEW KODAK
> > i700
> > Series Scanner you'll get full speed at 300 dpi even with all image
> > processing features enabled. http://p.sf.net/sfu/kodak-com
> > _______________________________________________
> > Libcg-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/libcg-devel
> >
>
--
regards,
Dhaval
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel