util/token: rename TOKEN_STRLEN to TOKEN_SIZE

TOKEN_STRLEN is not actually the strlen() of the token. It's the
size taken by the token included the final zero byte.

Change the name to make this clearer, and remove unnecessary +1's.
This commit is contained in:
Simon Ser 2023-10-06 16:08:28 +02:00 committed by Kirill Primak
parent 3232697252
commit 55be74ad86
3 changed files with 7 additions and 6 deletions

View file

@ -11,7 +11,7 @@
#include <sys/stat.h>
#include <unistd.h>
bool generate_token(char out[static TOKEN_STRLEN]) {
bool generate_token(char out[static TOKEN_SIZE]) {
static FILE *urandom = NULL;
uint64_t data[2];
@ -31,7 +31,7 @@ bool generate_token(char out[static TOKEN_STRLEN]) {
wlr_log_errno(WLR_ERROR, "Failed to read from random device");
return false;
}
if (snprintf(out, TOKEN_STRLEN, "%016" PRIx64 "%016" PRIx64, data[0], data[1]) != TOKEN_STRLEN - 1) {
if (snprintf(out, TOKEN_SIZE, "%016" PRIx64 "%016" PRIx64, data[0], data[1]) != TOKEN_SIZE - 1) {
wlr_log_errno(WLR_ERROR, "Failed to format hex string token");
return false;
}