Skip to content

Commit

Permalink
Incorporate review
Browse files Browse the repository at this point in the history
  • Loading branch information
vornkat-iis committed Jan 19, 2024
1 parent 65561c2 commit d3e390e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/japi.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ int japi_destroy(japi_context *ctx);
* -2 for empty request name,
* -3 for empty request handler,
* -4 for duplicate naming,
* -5 for failed memory allocation, is returned.
* -5 for failed memory allocation,
* -6 for bad request name (starting with "japi_") is returned.
*/
int japi_register_request(japi_context *ctx, const char *req_name,
japi_req_handler req_handler);
Expand Down
2 changes: 1 addition & 1 deletion src/japi.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ int japi_register_request(japi_context *ctx, const char *req_name,

if (ctx->init && strncmp(req_name, bad_req_name, strlen(bad_req_name)) == 0) {
fprintf(stderr, "ERROR: Request name is not allowed.\n");
return -5;
return -6;
}

req = (japi_request *)malloc(sizeof(japi_request));
Expand Down
6 changes: 3 additions & 3 deletions src/japi_pushsrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void japi_pushsrv_subscribe(japi_context *ctx, json_object *jreq, json_object *j
pushsrv_name = json_object_get_string(jval);
ret = json_object_object_get_ex(jreq, "socket", &jval);
socket = json_object_get_int(jval);
if (!ret | socket < 0) {
if (!ret || socket < 0) {
json_object_object_add(jresp, "success", json_object_new_boolean(false));
json_object_object_add(
jresp, "message",
Expand All @@ -199,7 +199,7 @@ void japi_pushsrv_subscribe(japi_context *ctx, json_object *jreq, json_object *j
json_object_object_add(jresp, "service", json_object_new_string(pushsrv_name));

/* Create JSON response object */
if (psc == NULL | ret < 0) {
if (psc == NULL || ret < 0) {
json_object_object_add(jresp, "success", json_object_new_boolean(false));
json_object_object_add(jresp, "message",
json_object_new_string("Push service not found."));
Expand Down Expand Up @@ -237,7 +237,7 @@ void japi_pushsrv_unsubscribe(japi_context *ctx, json_object *jreq, json_object

ret = json_object_object_get_ex(jreq, "socket", &jval);
socket = json_object_get_int(jval);
if (!ret | socket < 0) {
if (!ret || socket < 0) {
json_object_object_add(jresp, "success", json_object_new_boolean(false));
json_object_object_add(
jresp, "message",
Expand Down

0 comments on commit d3e390e

Please sign in to comment.