commit 62cbcdae43d424ecc31a54bd67fd22a7120bf9fa from: Omar Polo date: Fri Feb 02 12:51:40 2024 UTC remove imsg_borrow_str it's redundant due to ibuf_borrow_str() commit - 54764e41a11e16a56da805313f209a9937c5173d commit + 62cbcdae43d424ecc31a54bd67fd22a7120bf9fa blob - 783a5da41098b7cb9ff34036723bdb5b45654344 blob + 7c47744a8aaf62dd8a7060b3b67a135a1dd415d7 --- telescope.c +++ telescope.c @@ -166,13 +166,16 @@ tab_by_id(uint32_t id) static void handle_imsg_check_cert(struct imsg *imsg) { - const char *hash, *host, *port; + char *hash; + const char *host, *port; int tofu_res; + struct ibuf ibuf; struct tofu_entry *e; struct tab *tab; size_t datalen; - if ((hash = imsg_borrow_str(imsg)) == NULL) + if (imsg_get_ibuf(imsg, &ibuf) == -1 || + ibuf_borrow_str(&ibuf, &hash) == -1) abort(); datalen = strlen(hash); @@ -462,7 +465,8 @@ handle_dispatch_imsg(int fd, short event, void *data) case IMSG_ERR: if ((tab = tab_by_id(imsg_get_id(&imsg))) == NULL) break; - if ((str = imsg_borrow_str(&imsg)) == NULL) + if (imsg_get_ibuf(&imsg, &ibuf) == -1 || + ibuf_borrow_str(&ibuf, &str) == -1) die(); if (asprintf(&page, "# Error loading %s\n\n> %s\n", hist_cur(tab->hist), str) == -1) blob - c6431d29c53306f0ff5022bde427ea5f47c86f68 blob + fc40369b423e13aa044a9089bfec117e2354b22c --- utils.c +++ utils.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Omar Polo + * Copyright (c) 2021, 2024 Omar Polo * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -95,18 +95,6 @@ imsg_compose_event(struct imsgev *iev, uint16_t type, return ret; } -char * -imsg_borrow_str(struct imsg *imsg) -{ - struct ibuf ibuf; - char *data; - - if (imsg_get_ibuf(imsg, &ibuf) == -1 || - ibuf_borrow_str(&ibuf, &data) == -1) - return NULL; - return data; -} - int ibuf_borrow_str(struct ibuf *ibuf, char **data) { blob - fe2c312b8a9a3f69151634576295d40fd21f2765 blob + 31b6325bd586f3d65c41bb56cb4bd7079883823d --- utils.h +++ utils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Omar Polo + * Copyright (c) 2022, 2024 Omar Polo * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -26,7 +26,6 @@ int unicode_isgraph(uint32_t); void imsg_event_add(struct imsgev *); int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t, int, const void *, uint16_t); -char *imsg_borrow_str(struct imsg *); int ibuf_borrow_str(struct ibuf *, char **); void *hash_alloc(size_t, void *);