From 67c6d4d1f1ee5c3a99c4f1a089c9acc836c7f191 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 24 Nov 2017 14:43:31 +0100 Subject: [PATCH] opts: Change alias to be u8*, better matches the unicode nature We are still generating only char* style aliases, but the field is defined to be unicode, which doesn't mix too well with char. Signed-off-by: Christian Decker --- lightningd/lightningd.h | 2 +- lightningd/options.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index ba53ed767..fd161f7c4 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -89,7 +89,7 @@ struct lightningd { struct pubkey id; /* My name is... my favorite color is... */ - char *alias; /* At least 32 bytes (zero-filled) */ + u8 *alias; /* At least 32 bytes (zero-filled) */ u8 *rgb; /* tal_len() == 3. */ /* Any pending timers. */ diff --git a/lightningd/options.c b/lightningd/options.c index 75923388c..b3a7979fa 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -168,8 +168,8 @@ static char *opt_set_alias(const char *arg, struct lightningd *ld) */ if (strlen(arg) > 32) return tal_fmt(NULL, "Alias '%s' is over 32 characters", arg); - ld->alias = tal_arrz(ld, char, 33); - strncpy(ld->alias, arg, 32); + ld->alias = tal_arrz(ld, u8, 33); + strncpy((char*)ld->alias, arg, 32); return NULL; } @@ -572,11 +572,11 @@ void setup_color_and_alias(struct lightningd *ld) memcpy(&noun, der+3+sizeof(adjective), sizeof(noun)); noun %= ARRAY_SIZE(codename_noun); adjective %= ARRAY_SIZE(codename_adjective); - ld->alias = tal_arrz(ld, char, 33); + ld->alias = tal_arrz(ld, u8, 33); assert(strlen(codename_adjective[adjective]) + strlen(codename_noun[noun]) < 33); - strcpy(ld->alias, codename_adjective[adjective]); - strcat(ld->alias, codename_noun[noun]); + strcpy((char*)ld->alias, codename_adjective[adjective]); + strcat((char*)ld->alias, codename_noun[noun]); } }