diff options
Diffstat (limited to 'src/libs/jobmanager/job_manager.c')
-rw-r--r-- | src/libs/jobmanager/job_manager.c | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/src/libs/jobmanager/job_manager.c b/src/libs/jobmanager/job_manager.c index bc654d7..2d1f55b 100644 --- a/src/libs/jobmanager/job_manager.c +++ b/src/libs/jobmanager/job_manager.c @@ -320,8 +320,10 @@ static gint cmp_job_file_names(gconstpointer a, guint64 fst_id; guint64 snd_id; - g_assert((fst_num_start = rindex(na, '-')) != NULL); - g_assert((snd_num_start = rindex(nb, '-')) != NULL); + fst_num_start = rindex(na, '-'); + g_assert(fst_num_start != NULL); + snd_num_start = rindex(nb, '-'); + g_assert(snd_num_start != NULL); ++fst_num_start; ++snd_num_start; fst_id = g_ascii_strtoull(fst_num_start, NULL, 10); @@ -1546,7 +1548,8 @@ static LmiJob *load_job_from_file(gchar const *job_file_path) gchar job_type_name[BUFLEN]; const gchar *basename; - g_assert((tmp = rindex(job_file_path, '-')) != NULL); + tmp = rindex(job_file_path, '-'); + g_assert(tmp != NULL); if ((basename = rindex(job_file_path, '/')) != NULL) { ++basename; } else { @@ -1554,7 +1557,7 @@ static LmiJob *load_job_from_file(gchar const *job_file_path) } lmi_debug("Loading job file \"%s\".", basename); strncpy(job_type_name, basename, MIN(tmp - basename, BUFLEN)); - job_type_name[MIN(tmp - basename, BUFLEN)] = 0; + job_type_name[MIN(tmp - basename, BUFLEN - 1)] = 0; if ((job_type = g_type_from_name(job_type_name)) == 0) { lmi_error("Job type \"%s\" is not known to glib type system.", job_type_name); @@ -2354,22 +2357,17 @@ err: CMPIStatus jobmgr_run_job(LmiJob *job) { CMPIStatus status = {CMPI_RC_OK, NULL}; - const JobTypeInfo *info; PendingJobKey *job_key = NULL; gchar *jobid; + GSource *source; g_assert(_initialized_counter); g_assert(LMI_IS_JOB(job)); - if ((info = lookup_job_type_info_for_job(job)) == NULL) { - CMSetStatus(&status, CMPI_RC_ERR_FAILED); - goto err; - } - JM_CRITICAL_CRITICAL_BEGIN; JOB_CRITICAL_BEGIN(job); if ((job_key = g_new(PendingJobKey, 1)) == NULL) { lmi_error("Memory allocation failed"); - goto job_lock_release; + goto err; } job_key->priority = lmi_job_get_priority(job); job_key->number = lmi_job_get_number(job); @@ -2379,23 +2377,21 @@ CMPIStatus jobmgr_run_job(LmiJob *job) g_free(jobid); CMSetStatusWithChars(_cb, &status, CMPI_RC_ERR_FAILED, "Job already started!"); - goto job_key_err; + goto err; } JOB_CRITICAL_END(job); g_tree_insert(_job_queue, job_key, job); - GSource *source = g_idle_source_new(); + source = g_idle_source_new(); g_source_set_callback(source, launch_jobs, NULL, NULL); g_source_attach(source, _main_ctx); JM_CRITICAL_CRITICAL_END; return status; -job_key_err: +err: g_free(job_key); -job_lock_release: JOB_CRITICAL_END(job); JM_CRITICAL_CRITICAL_END; -err: return status; } @@ -2532,7 +2528,6 @@ gchar **jobmgr_get_pending_job_ids(guint *count) return res; res_err: - g_free(res); while (ptr > res) g_free(*(--ptr)); g_free(res); @@ -2757,7 +2752,7 @@ LmiJob *jobmgr_get_job_by_name(const gchar *name) CMPIStatus jobmgr_job_to_cim_op(const LmiJob *job, CMPIObjectPath **op) { CMPIStatus status = {CMPI_RC_OK, NULL}; - gchar *namespace = NULL; + gchar *namespace; char instance_id[BUFLEN]; CMPIValue value; const JobTypeInfo *info; @@ -2772,10 +2767,10 @@ CMPIStatus jobmgr_job_to_cim_op(const LmiJob *job, CMPIObjectPath **op) } if ((namespace = lmi_read_config("CIM", "Namespace")) == NULL) goto err; - if ((*op = CMNewObjectPath(_cb, namespace, info->cim_class_name, - &status)) == NULL || status.rc) - goto namespace_err; + *op = CMNewObjectPath(_cb, namespace, info->cim_class_name, &status); g_free(namespace); + if (*op == NULL || status.rc) + goto err; g_snprintf(instance_id, BUFLEN, "LMI:%s:%u", info->cim_class_name, lmi_job_get_number(job)); @@ -2794,8 +2789,6 @@ string_err: CMRelease(value.string); op_err: CMRelease(*op); -namespace_err: - g_free(namespace); err: lmi_error("Memory allocation failed"); if (!status.rc) @@ -2893,14 +2886,13 @@ CMPIStatus jobmgr_job_to_method_result_instance(const LmiJob *job, CMPIValue value; CMPIData data; gchar buf[BUFLEN]; - const gchar *method_name; g_assert(instance); g_assert(LMI_IS_JOB(job)); g_assert(_initialized_counter > 0); JOB_CRITICAL_BEGIN(job); - if ((method_name = lmi_job_get_method_name(job)) == NULL) { + if (lmi_job_get_method_name(job) == NULL) { g_snprintf(buf, BUFLEN, "Can't create LMI_MethodResult instance" " out of job #%u with method-name unset.", lmi_job_get_number(job)); goto err; @@ -3214,7 +3206,6 @@ CMPIStatus jobmgr_get_job_matching_op(const CMPIObjectPath *path, { CMPIStatus status = {CMPI_RC_OK, NULL}; CMPIData data; - CMPIString *str; const char *instance_id; const char *class_name_start; const char *class_name_end; @@ -3223,11 +3214,9 @@ CMPIStatus jobmgr_get_job_matching_op(const CMPIObjectPath *path, LmiJob *jobptr = NULL; struct _JobTypeSearchContainer jtsc = {NULL, G_TYPE_INVALID}; const JobTypeInfo *info; - gchar error[BUFLEN]; + gchar error[BUFLEN] = ""; g_assert(_initialized_counter); - if ((str = CMGetClassName(path, &status)) == NULL) - return status; data = CMGetKey(path, "InstanceID", &status); if (status.rc) return status; |