On Monday, 6 August 2007 10:18, Alon Bar-Lev wrote:
> On 8/6/07, Frank Seidel <[EMAIL PROTECTED]> wrote:
> > On Monday 06 August 2007 00:46:01 Alon Bar-Lev wrote:
> > > On 8/6/07, Rafael J. Wysocki <[EMAIL PROTECTED]> wrote:
> > > > On Monday, 6 August 2007 00:05, Alon Bar-Lev wrote:
> > > > >
> > > > > Well... It never worked :)
> > > >
> > > > Why exactly do you think so?
> > >
> > > Because you increment buf and return it... This will not work with
> > > printf() as it always be an empty string.
> > ? Sorry, i also cannot see the problem you describe.
> > The way print_checksum worked until now can be found very
> > often (also e.g. inside the kernel) and it works just absolutely fine
> > for me.
> > Incrementing and returning buf (or any other non-constant function
> > parameter,
> > being just a kind of runtime-preset local variable) is nothing wrong,
> > special or abnormal.
> > And why should the sprintf always be/produce an empty string?
> > It will always give you 16 characters (not including the terminating zero).
> >
> > I really appreciate the effort you put into all this, but
> > this special patch is more or less just a artificial pad out.
> >
> > Thanks,
> > Frank
> >
>
> I MUST GOING CRAZY!!!!
> PLEASE WAKE ME UP!!!!
>
> Here is the original function:
>
> resume.c::378:
> static char * print_checksum(char * buf, unsigned char *checksum)
> {
> int j;
>
> for (j = 0; j < 16; j++)
> buf += sprintf(buf, "%02hhx ", checksum[j]);
>
> return buf;
> }
>
> Here is the usage:
>
> resume.c::584:
> printf("resume: MD5 checksum %s\n",
> print_checksum(buffer, orig_checksum));
> resume::701:
> fprintf(stderr,"resume: Computed MD5 checksum %s\n",
> print_checksum(buffer, checksum));
Yes, in this context you're right, but this was not clear from the original
post.
Moreover, the printf() is buggy, not the function itself.
Greetings,
Rafael
--
"Premature optimization is the root of all evil." - Donald Knuth
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Suspend-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/suspend-devel