mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
cli: change the redefine logic to read from the stdin
Procedure redefinition is a very cool feature but when other libraries redefine the same function can be very tricky to avoid compilation error. This PR proposed a change of logic and use a customizzation function definition to read from the stdin, so we can avoid future error at compile time. However, we could be check also the os or compiler that cause the error and redefine the missing function. Changelog-None: Fixed compilation error due redefinition procedure. Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
committed by
Christian Decker
parent
52b1f5a8f4
commit
35eaaf8e63
@@ -2,6 +2,7 @@
|
||||
* Helper to submit via JSON-RPC and get back response.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "config_cli.h"
|
||||
#include <ccan/asort/asort.h>
|
||||
#include <ccan/err/err.h>
|
||||
#include <ccan/json_escape/json_escape.h>
|
||||
@@ -15,7 +16,6 @@
|
||||
#include <common/utils.h>
|
||||
#include <common/version.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -386,7 +386,7 @@ static size_t read_nofail(int fd, void *buf, size_t len)
|
||||
ssize_t i;
|
||||
assert(len > 0);
|
||||
|
||||
i = read(fd, buf, len);
|
||||
i = cli_read(fd, buf, len);
|
||||
if (i == 0)
|
||||
errx(ERROR_TALKING_TO_LIGHTNINGD,
|
||||
"reading response: socket closed");
|
||||
@@ -572,7 +572,7 @@ static void enable_notifications(int fd)
|
||||
memset(rbuf, 0, sizeof(rbuf));
|
||||
while (!strends(rbuf, "\n\n")) {
|
||||
size_t len = strlen(rbuf);
|
||||
if (read(fd, rbuf + len, sizeof(rbuf) - len) < 0)
|
||||
if (cli_read(fd, rbuf + len, sizeof(rbuf) - len) < 0)
|
||||
err(ERROR_TALKING_TO_LIGHTNINGD,
|
||||
"Reading enable response");
|
||||
}
|
||||
@@ -756,7 +756,7 @@ int main(int argc, char *argv[])
|
||||
while (parserr <= 0) {
|
||||
/* Read more if parser says, or we have 0 tokens. */
|
||||
if (parserr == 0 || parserr == JSMN_ERROR_PART) {
|
||||
ssize_t i = read(fd, resp + off, tal_bytelen(resp) - 1 - off);
|
||||
ssize_t i = cli_read(fd, resp + off, tal_bytelen(resp) - 1 - off);
|
||||
if (i == 0)
|
||||
errx(ERROR_TALKING_TO_LIGHTNINGD,
|
||||
"reading response: socket closed");
|
||||
|
||||
Reference in New Issue
Block a user