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)); Does anybody but me can also tell that the checksum will never be printed? My simple programming experience tells me that if you put in buffer with value of X, you get result of X+strlen (x), which will always be pointer to { '\x0' } and this what goes into printf(). I can explain more if you like... How printf works, how it scans for parameters etc... This problem can be solved using my patch or if you so like this kernel programming you can do this without changing the print_checksum function: resume.c::584: print_checksum(buffer, orig_checksum); printf("resume: MD5 checksum %s\n", buffer); resume::701: print_checksum(buffer, checksum); fprintf(stderr,"resume: Computed MD5 checksum %s\n", buffer); Alon. ------------------------------------------------------------------------- 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 Suspend-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/suspend-devel