tpm: use %*ph to print small buffer
Subsystems (2)
PATCH 1/1 tpm: use %*ph to print small buffer
Use %*ph format to print small buffer as hex string.
--- drivers/char/tpm/tpm-sysfs.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-)
drivers/char/tpm/tpm-sysfs.c +10 -21
@@ -56,31 +56,20 @@ static ssize_t pubek_show(struct device *dev, struct device_attribute *attr, out = (struct tpm_readpubek_out *)&tpm_buf.data[10 ]; str +=sprintf (str, -"Algorithm: %02X %02X %02X %02X\n" -"Encscheme: %02X %02X\n" -"Sigscheme: %02X %02X\n" -"Parameters: %02X %02X %02X %02X " -"%02X %02X %02X %02X " -"%02X %02X %02X %02X\n" +"Algorithm: %4ph\n" +"Encscheme: %2ph\n" +"Sigscheme: %2ph\n" +"Parameters: %12ph\n" "Modulus length: %d\n" "Modulus:\n" , - out->algorithm[0 ], out->algorithm[1 ], out->algorithm[2 ], - out->algorithm[3 ], - out->encscheme[0 ], out->encscheme[1 ], - out->sigscheme[0 ], out->sigscheme[1 ], - out->parameters[0 ], out->parameters[1 ], - out->parameters[2 ], out->parameters[3 ], - out->parameters[4 ], out->parameters[5 ], - out->parameters[6 ], out->parameters[7 ], - out->parameters[8 ], out->parameters[9 ], - out->parameters[10 ], out->parameters[11 ], + out->algorithm, + out->encscheme, + out->sigscheme, + out->parameters,be32_to_cpu (out->keysize)); -for (i =0 ; i <256 ; i++) { - str +=sprintf (str,"%02X " , out->modulus[i]); -if ((i +1 ) %16 ==0 ) - str +=sprintf (str,"\n" ); - } +for (i =0 ; i <256 ; i +=16 ) + str +=sprintf (str,"%16ph\n" , &out->modulus[i]); out_buf:tpm_buf_destroy (&tpm_buf);
Signature · 1 line
2.27.0
Hi,
Quoted 1 line
Use %*ph format to print small buffer as hex string.
Kind regards,
Petr
Quoted 7 lines · Petr Vorel
Hi,
Quoted 1 line
Use %*ph format to print small buffer as hex string.
Reviewed-by Petr Vorel <[email protected]>Kind regards,
Petr
Thanks, I'll add this to the commit.
/Jarkko
Quoted 3 lines · Andy Shevchenko
Use %*ph format to print small buffer as hex string.
Signed-off-by Andy Shevchenko <[email protected]>
Oh, this is handy, thanks.
/Jarkko
Quoted 8 lines · Jarkko Sakkinen
Quoted 3 lines · Andy Shevchenko
Use %*ph format to print small buffer as hex string.
Signed-off-by Andy Shevchenko <[email protected]>Oh, this is handy, thanks.
Reviewed-by Jarkko Sakkinen <[email protected]>
Thanks!
Anybody to push this?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 5 lines · Jarkko Sakkinen
Quoted 3 lines · Andy Shevchenko
Use %*ph format to print small buffer as hex string.
Signed-off-by Andy Shevchenko <[email protected]>
Quoted 7 lines
Quoted 3 lines
Oh, this is handy, thanks.
Reviewed-by Jarkko Sakkinen <[email protected]>Thanks!
Anybody to push this?
It's in my tree git://git.infradead.org/users/jjs/linux-tpmdd.git
So next I'll put it to the next PR.
/Jarkko
Quoted 11 lines · Jarkko Sakkinen
Quoted 10 lines · Andy Shevchenko
Quoted 8 lines · Jarkko Sakkinen
Quoted 3 lines · Andy Shevchenko
Use %*ph format to print small buffer as hex string.
Signed-off-by Andy Shevchenko <[email protected]>Oh, this is handy, thanks.
Reviewed-by Jarkko Sakkinen <[email protected]>
Quoted 7 lines
Quoted 3 lines
Thanks!
Anybody to push this?
It's in my tree
git://git.infradead.org/users/jjs/linux-tpmdd.gitSo next I'll put it to the next PR.
Thanks!
P.S. I don't see your tree connected to Linux Next, perhaps you can ask Stephen to add it?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 16 lines · Andy Shevchenko
Quoted 15 lines · Jarkko Sakkinen
Quoted 13 lines · Andy Shevchenko
Quoted 8 lines · Jarkko Sakkinen
Quoted 3 lines · Andy Shevchenko
Use %*ph format to print small buffer as hex string.
Signed-off-by Andy Shevchenko <[email protected]>Oh, this is handy, thanks.
Reviewed-by Jarkko Sakkinen <[email protected]>Thanks!
Anybody to push this?
Quoted 8 lines
Quoted 3 lines
It's in my tree
git://git.infradead.org/users/jjs/linux-tpmdd.gitSo next I'll put it to the next PR.
Thanks!
P.S. I don't see your tree connected to Linux Next, perhaps you can ask Stephen to add it?
The next branch is connected to the linux-next. I've just forgot to rebase that branch (will do now).
Quoted 3 lines
Signature · 2 lines
With Best Regards, Andy Shevchenko
/Jarkko