-
Notifications
You must be signed in to change notification settings - Fork 942
json-rpc: translate NULL into "null" instead of "(null)". #1118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I believe this is the point which we should modify: lightning/lightningd/jsonrpc.c Lines 687 to 689 in 73cda2f
It should be Then inside both |
Agreed: that seems to be somewhat less ugly than what I made. Could we somehow ensure that NULL is never passed to tal_fmt through another route? I find it scary to have stumbled upon something that is actually undefined behavior. |
Wait for @practicalswift to do regular undefined behavior checking has always been my personal technique, hahaha. |
Was about to suggest the same as @ZmnSCPxj : let's kill the root cause, and assert() that it never happens again. |
On a more serious note, @bitonic-cjp: undefined behavior is mostly caught by code review and sometimes by automated tools that scan for them, and |
…ver receive NULL arguments. Pass "null" instead, where needed.
I did what ZmnSCPxj said; now I'm checking other tal_fmt calls. |
ACK 59b7f9e |
lightningd/jsonrpc.c
Outdated
@@ -263,6 +263,8 @@ static void connection_complete_ok(struct json_connection *jcon, | |||
const char *id, | |||
const struct json_result *result) | |||
{ | |||
assert(id != NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Make sure the indentation matches the surrounding code. Same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed; I already discovered this myself, and was going to fix it.
ACK 500db24 |
It turns out that #957 is insufficient to solve #908 . This fix is needed to really say "id": null instead of "id": (null).
This is probably an incomplete fix: it would be better to make sure that all cases of NULL are translated into "null". However, I didn't want to touch the tal_fmt implementation. What would be a good approach? make a json_fmt wrapper around tal_fmt to do this? I didn't do this yet: since I'm not too familiar with the code base yet, I didn't want to make too large changes without any guidance.