Merge authors: James Hunt (jamesodhunt) Related merge proposals: https://code.launchpad.net/~jamesodhunt/upstart/fix-deprecated-json-calls/+merge/218664 proposed by: James Hunt (jamesodhunt) review: Approve - Colin Watson (cjwatson) ------------------------------------------------------------ revno: 1619 [merge] committer: James Hunt <[email protected]> branch nick: upstart timestamp: Thu 2014-05-08 08:55:40 +0100 message: * Merge of lp:~jamesodhunt/upstart/fix-deprecated-json-calls. modified: ChangeLog init/conf.c init/event.c init/event_operator.c init/job.c init/job_class.c init/log.c init/process.c init/session.c init/state.c init/tests/test_conf.c
-- lp:upstart https://code.launchpad.net/~upstart-devel/upstart/trunk Your team Upstart Reviewers is subscribed to branch lp:upstart. To unsubscribe from this branch go to https://code.launchpad.net/~upstart-devel/upstart/trunk/+edit-subscription
=== modified file 'ChangeLog' --- ChangeLog 2014-04-24 12:39:18 +0000 +++ ChangeLog 2014-05-07 16:34:44 +0000 @@ -1,3 +1,8 @@ +2014-05-07 James Hunt <[email protected]> + + * Convert calls to deprecated json_object_object_get() to + json_object_object_get_ex(). + 2014-04-24 James Hunt <[email protected]> * init/man/init.5: === modified file 'init/conf.c' --- init/conf.c 2014-01-17 12:03:24 +0000 +++ init/conf.c 2014-05-07 16:34:44 +0000 @@ -1526,10 +1526,8 @@ nih_assert (NIH_LIST_EMPTY (conf_sources)); - json_conf_sources = json_object_object_get (json, "conf_sources"); - - if (! json_conf_sources) - goto error; + if (! json_object_object_get_ex (json, "conf_sources", &json_conf_sources)) + goto error; if (! state_check_json_type (json_conf_sources, array)) goto error; @@ -1770,10 +1768,8 @@ conf_init (); - json_conf_files = json_object_object_get (json, "conf_files"); - - if (! json_conf_files) - goto error; + if (! json_object_object_get_ex (json, "conf_files", &json_conf_files)) + goto error; if (! state_check_json_type (json_conf_files, array)) goto error; === modified file 'init/event.c' --- init/event.c 2013-09-27 16:02:42 +0000 +++ init/event.c 2014-05-07 16:34:44 +0000 @@ -672,7 +672,7 @@ if (! state_get_json_string_var_strict (json, "name", NULL, name)) goto error; - if (json_object_object_get (json, "env")) { + if (json_object_object_get_ex (json, "env", NULL)) { if (! state_get_json_var_full (json, "env", array, json_env)) goto error; @@ -706,7 +706,7 @@ * possible to manually reconstruct the state of the * EventOperators post-re-exec. */ - if (json_object_object_get (json, "blockers")) { + if (json_object_object_get_ex (json, "blockers", NULL)) { if (! state_get_json_int_var_to_obj (json, event, blockers)) goto error; } @@ -737,9 +737,8 @@ event_init (); nih_assert (NIH_LIST_EMPTY (events)); - json_events = json_object_object_get (json, "events"); - if (! json_events) + if (! json_object_object_get_ex (json, "events", &json_events)) goto error; if (! state_check_json_type (json_events, array)) === modified file 'init/event_operator.c' --- init/event_operator.c 2013-05-08 16:21:08 +0000 +++ init/event_operator.c 2014-05-07 16:34:44 +0000 @@ -1022,7 +1022,7 @@ if (! state_check_json_type (json, object)) goto error; - if (json_object_object_get (json, "name")) { + if (json_object_object_get_ex (json, "name", NULL)) { if (! state_get_json_string_var_strict (json, "name", NULL, name)) goto error; } @@ -1032,7 +1032,7 @@ "type", type)) goto error; - if (json_object_object_get (json, "env")) { + if (json_object_object_get_ex (json, "env", NULL)) { json_object *json_env; if (! state_get_json_var_full (json, "env", array, json_env)) goto error; @@ -1054,7 +1054,7 @@ if (! state_get_json_int_var_to_obj (json, oper, value)) goto error; - if (json_object_object_get (json, "event")) { + if (json_object_object_get_ex (json, "event", NULL)) { int event_index; if (! state_get_json_int_var (json, "event", event_index)) === modified file 'init/job.c' --- init/job.c 2013-11-18 16:38:32 +0000 +++ init/job.c 2014-05-07 16:34:44 +0000 @@ -1831,7 +1831,6 @@ nih_local char *name = NULL; Job *job = NULL; json_object *json_kill_timer; - json_object *blocker; json_object *json_fds; json_object *json_pid; json_object *json_logs; @@ -1930,9 +1929,7 @@ /* blocking is handled by state_deserialise_blocking() */ - blocker = json_object_object_get (json, "blocker"); - - if (blocker) { + if (json_object_object_get_ex (json, "blocker", NULL)) { int event_index = -1; if (! state_get_json_int_var (json, "blocker", event_index)) @@ -1951,9 +1948,8 @@ /* Check to see if a kill timer exists first since we do not * want to end up creating a real but empty timer. */ - json_kill_timer = json_object_object_get (json, "kill_timer"); - if (json_kill_timer) { + if (json_object_object_get_ex (json, "kill_timer", &json_kill_timer)) { /* Found a partial kill timer, so create a new one and * adjust its due time. By the time the main loop gets * called, the due time will probably be in the past @@ -1997,8 +1993,7 @@ if (! state_get_json_int_var_to_obj (json, job, respawn_count)) goto error; - json_fds = json_object_object_get (json, "fds"); - if (! json_fds) + if (! json_object_object_get_ex (json, "fds", &json_fds)) goto error; ret = state_deserialise_int_array (job, json_fds, @@ -2006,8 +2001,7 @@ if (ret < 0) goto error; - json_pid = json_object_object_get (json, "pid"); - if (! json_pid) + if (! json_object_object_get_ex (json, "pid", &json_pid)) goto error; ret = state_deserialise_int_array (job, json_pid, @@ -2039,9 +2033,7 @@ "trace_state", job->trace_state)) goto error; - json_logs = json_object_object_get (json, "log"); - - if (! json_logs) + if (! json_object_object_get_ex (json, "log", &json_logs)) goto error; if (! state_check_json_type (json_logs, array)) @@ -2097,9 +2089,7 @@ nih_assert (parent); nih_assert (json); - json_jobs = json_object_object_get (json, "jobs"); - - if (! json_jobs) + if (! json_object_object_get_ex (json, "jobs", &json_jobs)) goto error; if (! state_check_json_type (json_jobs, array)) === modified file 'init/job_class.c' --- init/job_class.c 2014-01-31 12:42:18 +0000 +++ init/job_class.c 2014-05-07 16:34:44 +0000 @@ -2294,7 +2294,7 @@ goto error; /* reload_signal is new in upstart 1.10+ */ - if (json_object_object_get (json, "reload_signal")) { + if (json_object_object_get_ex (json, "reload_signal", NULL)) { if (! state_get_json_int_var_to_obj (json, class, reload_signal)) goto error; } @@ -2346,13 +2346,12 @@ /* If we are missing this, we're probably importing from a * previous version that didn't include PROCESS_SECURITY. */ - if (json_object_object_get (json, "apparmor_switch")) { + if (json_object_object_get_ex (json, "apparmor_switch", NULL)) { if (! state_get_json_string_var_to_obj (json, class, apparmor_switch)) goto error; } - json_normalexit = json_object_object_get (json, "normalexit"); - if (! json_normalexit) + if (! json_object_object_get_ex (json, "normalexit", &json_normalexit)) goto error; ret = state_deserialise_int_array (class, json_normalexit, @@ -2412,9 +2411,7 @@ job_class_init (); - json_classes = json_object_object_get (json, "job_classes"); - - if (! json_classes) + if (! json_object_object_get_ex (json, "job_classes", &json_classes)) goto error; if (! state_check_json_type (json_classes, array)) === modified file 'init/log.c' --- init/log.c 2013-06-26 12:10:23 +0000 +++ init/log.c 2014-05-07 16:34:44 +0000 @@ -949,7 +949,6 @@ nih_local char *unflushed = NULL; int ret; size_t len; - json_object *json_unflushed; nih_local char *path = NULL; int io_watch_fd = -1; uid_t uid = (uid_t)-1; @@ -1000,8 +999,7 @@ if (! log->unflushed) goto error; - json_unflushed = json_object_object_get (json, "unflushed"); - if (json_unflushed) { + if (json_object_object_get_ex (json, "unflushed", NULL)) { if (! state_get_json_string_var_strict (json, "unflushed", NULL, unflushed_hex)) goto error; === modified file 'init/process.c' --- init/process.c 2013-05-23 17:16:03 +0000 +++ init/process.c 2014-05-07 16:34:44 +0000 @@ -267,9 +267,7 @@ nih_assert (parent); nih_assert (processes); - json_processes = json_object_object_get (json, "process"); - - if (! json_processes) + if (! json_object_object_get_ex (json, "process", &json_processes)) goto error; if (! state_check_json_type (json_processes, array)) === modified file 'init/session.c' --- init/session.c 2014-04-11 21:15:39 +0000 +++ init/session.c 2014-05-07 16:34:44 +0000 @@ -407,9 +407,7 @@ nih_assert (NIH_LIST_EMPTY (sessions)); - json_sessions = json_object_object_get (json, "sessions"); - - if (! json_sessions) + if (! json_object_object_get_ex (json, "sessions", &json_sessions)) goto error; if (! state_check_json_type (json_sessions, array)) === modified file 'init/state.c' --- init/state.c 2013-12-12 16:37:16 +0000 +++ init/state.c 2014-05-07 16:34:44 +0000 @@ -492,7 +492,7 @@ /* Again, we cannot error here since older JSON state data did * not encode ConfSource or ConfFile objects. */ - if (json_object_object_get (json, "conf_sources")) { + if (json_object_object_get_ex (json, "conf_sources", NULL)) { if (conf_source_deserialise_all (json) < 0) { nih_error ("%s ConfSources", _("Failed to deserialise")); goto out; @@ -501,9 +501,7 @@ nih_warn ("%s", _("No ConfSources present in state data")); } - json_job_environ = json_object_object_get (json, "job_environment"); - - if (json_job_environ) { + if (json_object_object_get_ex (json, "job_environment", &json_job_environ)) { if (job_class_deserialise_job_environ (json_job_environ) < 0) { nih_error ("%s global job environment", _("Failed to deserialise")); @@ -1066,9 +1064,7 @@ nih_assert (parent); nih_assert (rlimits); - json_limits = json_object_object_get (json, "limits"); - - if (! json_limits) + if (! json_object_object_get_ex (json, "limits", &json_limits)) goto error; if (! state_check_json_type (json_limits, array)) @@ -1330,8 +1326,7 @@ if (! state_check_json_type (json_job, object)) goto error; - json_blocking = json_object_object_get (json_job, "blocking"); - if (! json_blocking) + if (! json_object_object_get_ex (json_job, "blocking", &json_blocking)) continue; if (! state_get_json_string_var_strict (json_job, "name", NULL, job_name)) @@ -1598,8 +1593,7 @@ if (blocked_type == (BlockedType)-1) goto error; - json_blocked_data = json_object_object_get (json, "data"); - if (! json_blocked_data) + if (! json_object_object_get_ex (json, "data", &json_blocked_data)) goto error; switch (blocked_type) { @@ -1776,11 +1770,10 @@ nih_assert (list); nih_assert (json); - json_blocking = json_object_object_get (json, "blocking"); - - /* parent is not blocking anything */ - if (! json_blocking) + if (! json_object_object_get_ex (json, "blocking", &json_blocking)) { + /* parent is not blocking anything */ return 0; + } for (int i = 0; i < json_object_array_length (json_blocking); i++) { json_object * json_blocked; === modified file 'init/tests/test_conf.c' --- init/tests/test_conf.c 2014-01-17 12:03:24 +0000 +++ init/tests/test_conf.c 2014-05-07 16:34:44 +0000 @@ -4550,7 +4550,7 @@ TEST_NE_P (json, NULL); /* Test there is no JobClass in the JSON */ - TEST_EQ_P (json_object_object_get (json, "job_class"), NULL); + TEST_EQ (json_object_object_get_ex (json, "job_class", NULL), FALSE); TEST_FEATURE ("ConfFile with no JobClass can be deserialised");
-- upstart-devel mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/upstart-devel
