From f9436b840852218b39dce22d6057b6f223168daa Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 23 May 2017 23:11:57 +0200 Subject: [PATCH] please codacy: use long form of negation in C++ and clang-format got annoying on this one --- examples/s4u/dht-chord/s4u_dht-chord.cpp | 6 +- src/bindings/java/jmsg.cpp | 4 +- src/bindings/java/jmsg_as.cpp | 18 +- src/bindings/java/jmsg_comm.cpp | 10 +- src/bindings/java/jmsg_host.cpp | 46 ++--- src/bindings/java/jmsg_process.cpp | 26 +-- src/bindings/java/jmsg_rngstream.cpp | 18 +- src/bindings/java/jmsg_storage.cpp | 26 +-- src/bindings/java/jmsg_task.cpp | 49 +++--- src/bindings/java/jmsg_vm.cpp | 6 +- src/bindings/java/jxbt_utilities.cpp | 26 +-- src/bindings/lua/lua_debug.cpp | 2 +- src/bindings/lua/lua_host.cpp | 2 +- src/bindings/lua/lua_platf.cpp | 33 ++-- src/instr/instr_config.cpp | 12 +- src/instr/instr_interface.cpp | 42 ++--- src/instr/instr_paje_containers.cpp | 4 +- src/instr/instr_paje_trace.cpp | 35 ++-- src/instr/instr_paje_types.cpp | 2 +- src/instr/instr_resource_utilization.cpp | 12 +- src/instr/jedule/jedule.cpp | 4 +- src/instr/jedule/jedule_events.cpp | 8 +- src/instr/jedule/jedule_platform.cpp | 8 +- src/instr/jedule/jedule_sd_binding.cpp | 2 +- src/kernel/activity/MailboxImpl.cpp | 2 +- src/kernel/activity/SynchroComm.cpp | 8 +- src/kernel/activity/SynchroExec.cpp | 2 +- src/kernel/activity/SynchroSleep.cpp | 2 +- src/kernel/context/ContextBoost.cpp | 8 +- src/kernel/context/ContextThread.cpp | 2 +- src/kernel/routing/ClusterZone.cpp | 10 +- src/kernel/routing/DijkstraZone.cpp | 14 +- src/kernel/routing/FatTreeZone.cpp | 2 +- src/kernel/routing/FloydZone.cpp | 10 +- src/kernel/routing/FullZone.cpp | 6 +- src/kernel/routing/NetZoneImpl.cpp | 6 +- src/kernel/routing/RoutedZone.cpp | 16 +- src/kernel/routing/TorusZone.cpp | 2 +- src/kernel/routing/VivaldiZone.cpp | 2 +- src/mc/DwarfExpression.cpp | 8 +- src/mc/LocationList.cpp | 6 +- src/mc/ModelChecker.cpp | 4 +- src/mc/ObjectInformation.cpp | 6 +- src/mc/Process.cpp | 20 +-- .../CommunicationDeterminismChecker.cpp | 31 ++-- src/mc/checker/LivenessChecker.cpp | 17 +- src/mc/checker/SafetyChecker.cpp | 6 +- src/mc/compare.cpp | 43 ++--- src/mc/mc_base.cpp | 10 +- src/mc/mc_checkpoint.cpp | 21 +-- src/mc/mc_client_api.cpp | 18 +- src/mc/mc_config.cpp | 4 +- src/mc/mc_dwarf.cpp | 27 ++- src/mc/mc_global.cpp | 2 +- src/mc/mc_memory.cpp | 2 +- src/mc/mc_record.cpp | 7 +- src/mc/mc_request.cpp | 2 +- src/mc/mc_snapshot.cpp | 12 +- src/mc/mc_state.cpp | 6 +- src/mc/mc_unw.cpp | 4 +- src/mc/mc_xbt.cpp | 2 +- src/mc/remote/Client.cpp | 8 +- src/msg/msg_actions.cpp | 2 +- src/msg/msg_global.cpp | 2 +- src/msg/msg_gos.cpp | 7 +- src/msg/msg_io.cpp | 4 +- src/msg/msg_process.cpp | 4 +- src/msg/msg_vm.cpp | 14 +- src/plugins/vm/VirtualMachineImpl.cpp | 2 +- src/plugins/vm/VmHostExt.cpp | 2 +- src/s4u/s4u_engine.cpp | 2 +- src/s4u/s4u_host.cpp | 2 +- src/s4u/s4u_mailbox.cpp | 2 +- src/simdag/sd_daxloader.cpp | 8 +- src/simdag/sd_dotloader.cpp | 8 +- src/simdag/sd_global.cpp | 11 +- src/simdag/sd_task.cpp | 12 +- src/simgrid/host.cpp | 2 +- src/simgrid/sg_config.cpp | 32 ++-- src/simix/ActorImpl.cpp | 26 +-- src/simix/libsmx.cpp | 2 +- src/simix/popping.cpp | 2 +- src/simix/smx_context.cpp | 12 +- src/simix/smx_deployment.cpp | 4 +- src/simix/smx_global.cpp | 18 +- src/simix/smx_host.cpp | 8 +- src/simix/smx_network.cpp | 21 ++- src/simix/smx_synchro.cpp | 2 +- src/smpi/SmpiHost.cpp | 2 +- src/smpi/colls/allgather/allgather-2dmesh.cpp | 2 +- src/smpi/colls/allgather/allgather-3dmesh.cpp | 2 +- .../colls/allgather/allgather-mvapich-smp.cpp | 8 +- .../allgather/allgather-spreading-simple.cpp | 2 +- .../allgatherv/allgatherv-mpich-ring.cpp | 26 ++- .../colls/allreduce/allreduce-smp-rsag-lr.cpp | 2 +- .../colls/allreduce/allreduce-smp-rsag.cpp | 2 +- src/smpi/colls/alltoall/alltoall-2dmesh.cpp | 2 +- src/smpi/colls/alltoall/alltoall-3dmesh.cpp | 2 +- src/smpi/colls/bcast/bcast-mvapich-smp.cpp | 41 ++--- .../bcast/bcast-scatter-rdb-allgather.cpp | 16 +- src/smpi/colls/coll_tuned_topo.cpp | 37 ++-- src/smpi/colls/gather/gather-mvapich.cpp | 143 ++++++++-------- src/smpi/colls/reduce/reduce-binomial.cpp | 2 +- src/smpi/colls/reduce/reduce-ompi.cpp | 6 +- .../colls/reduce/reduce-scatter-gather.cpp | 2 +- .../reduce_scatter/reduce_scatter-mpich.cpp | 2 +- .../reduce_scatter/reduce_scatter-ompi.cpp | 2 +- .../scatter/scatter-mvapich-two-level.cpp | 162 ++++++++---------- src/smpi/colls/scatter/scatter-ompi.cpp | 2 +- src/smpi/colls/smpi_automatic_selector.cpp | 104 +++++------ src/smpi/colls/smpi_default_selector.cpp | 4 +- src/smpi/colls/smpi_mpich_selector.cpp | 38 ++-- src/smpi/colls/smpi_mvapich2_selector.cpp | 57 +++--- src/smpi/colls/smpi_openmpi_selector.cpp | 18 +- src/smpi/instr_smpi.cpp | 74 ++++---- src/smpi/smpi_coll.cpp | 4 +- src/smpi/smpi_comm.cpp | 2 +- src/smpi/smpi_datatype.cpp | 12 +- src/smpi/smpi_deployment.cpp | 2 +- src/smpi/smpi_global.cpp | 17 +- src/smpi/smpi_memory.cpp | 11 +- src/smpi/smpi_op.cpp | 2 +- src/smpi/smpi_pmpi.cpp | 94 +++++----- src/smpi/smpi_replay.cpp | 14 +- src/smpi/smpi_request.cpp | 23 ++- src/smpi/smpi_shared.cpp | 5 +- src/smpi/smpi_static_variables.cpp | 2 +- src/surf/HostImpl.cpp | 6 +- src/surf/PropertyHolder.cpp | 4 +- src/surf/cpu_cas01.cpp | 10 +- src/surf/cpu_ti.cpp | 12 +- src/surf/fair_bottleneck.cpp | 6 +- src/surf/instr_routing.cpp | 24 +-- src/surf/instr_surf.cpp | 6 +- src/surf/lagrange.cpp | 60 +++---- src/surf/maxmin.cpp | 57 +++--- src/surf/network_cm02.cpp | 12 +- src/surf/network_ib.cpp | 2 +- src/surf/network_interface.cpp | 4 +- src/surf/network_ns3.cpp | 14 +- src/surf/plugins/host_energy.cpp | 6 +- src/surf/ptask_L07.cpp | 6 +- src/surf/sg_platf.cpp | 18 +- src/surf/storage_interface.cpp | 4 +- src/surf/storage_n11.cpp | 8 +- src/surf/surf_interface.cpp | 16 +- src/surf/trace_mgr.cpp | 2 +- src/surf/xml/surfxml_parseplatf.cpp | 6 +- src/surf/xml/surfxml_sax_cb.cpp | 6 +- src/xbt/backtrace_linux.cpp | 14 +- src/xbt/config.cpp | 8 +- src/xbt/cunit.cpp | 28 +-- src/xbt/dict.cpp | 34 ++-- src/xbt/dynar.cpp | 36 ++-- src/xbt/ex.cpp | 4 +- src/xbt/memory_map.cpp | 2 +- src/xbt/parmap.cpp | 2 +- src/xbt/xbt_replay.cpp | 4 +- src/xbt/xbt_str.cpp | 66 ++++--- .../task_destroy_cancel.cpp | 4 +- teshsuite/s4u/listen_async/listen_async.cpp | 4 +- .../storage_client_server.cpp | 4 +- teshsuite/simdag/flatifier/flatifier.cpp | 6 +- teshsuite/surf/maxmin_bench/maxmin_bench.cpp | 18 +- teshsuite/xbt/mmalloc/mmalloc_test.cpp | 4 +- 165 files changed, 1195 insertions(+), 1250 deletions(-) diff --git a/examples/s4u/dht-chord/s4u_dht-chord.cpp b/examples/s4u/dht-chord/s4u_dht-chord.cpp index 68239898c9..db79af6405 100644 --- a/examples/s4u/dht-chord/s4u_dht-chord.cpp +++ b/examples/s4u/dht-chord/s4u_dht-chord.cpp @@ -46,14 +46,14 @@ int main(int argc, char* argv[]) "\tExample: %s ../msg_platform.xml chord.xml\n", argv[0], argv[0]); char** options = &argv[1]; - while (!strncmp(options[0], "-", 1)) { + while (not strncmp(options[0], "-", 1)) { unsigned int length = strlen("-nb_bits="); - if (!strncmp(options[0], "-nb_bits=", length) && strlen(options[0]) > length) { + if (not strncmp(options[0], "-nb_bits=", length) && strlen(options[0]) > length) { nb_bits = xbt_str_parse_int(options[0] + length, "Invalid nb_bits parameter: %s"); XBT_DEBUG("Set nb_bits to %d", nb_bits); } else { length = strlen("-timeout="); - if (!strncmp(options[0], "-timeout=", length) && strlen(options[0]) > length) { + if (not strncmp(options[0], "-timeout=", length) && strlen(options[0]) > length) { timeout = xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s"); XBT_DEBUG("Set timeout to %d", timeout); } else { diff --git a/src/bindings/java/jmsg.cpp b/src/bindings/java/jmsg.cpp index a677fdaed3..abb1bacc0e 100644 --- a/src/bindings/java/jmsg.cpp +++ b/src/bindings/java/jmsg.cpp @@ -174,12 +174,12 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNI { msg_netzone_t as = MSG_zone_get_root(); jobject jas = jnetzone_new_instance(env); - if (!jas) { + if (not jas) { jxbt_throw_jni(env, "java As instantiation failed"); return nullptr; } jas = jnetzone_ref(env, jas); - if (!jas) { + if (not jas) { jxbt_throw_jni(env, "new global ref allocation failed"); return nullptr; } diff --git a/src/bindings/java/jmsg_as.cpp b/src/bindings/java/jmsg_as.cpp index 09d996d2e2..af1aa6fd08 100644 --- a/src/bindings/java/jmsg_as.cpp +++ b/src/bindings/java/jmsg_as.cpp @@ -68,24 +68,24 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getSons(JNIEnv * env, job jclass cls = env->FindClass("org/simgrid/msg/As"); - if (!cls) + if (not cls) return nullptr; jtable = env->NewObjectArray(static_cast(self_as->children()->size()), cls, nullptr); - if (!jtable) { + if (not jtable) { jxbt_throw_jni(env, "Hosts table allocation failed"); return nullptr; } for (auto tmp_as : *self_as->children()) { jobject tmp_jas = jnetzone_new_instance(env); - if (!tmp_jas) { + if (not tmp_jas) { jxbt_throw_jni(env, "java As instantiation failed"); return nullptr; } tmp_jas = jnetzone_ref(env, tmp_jas); - if (!tmp_jas) { + if (not tmp_jas) { jxbt_throw_jni(env, "new global ref allocation failed"); return nullptr; } @@ -100,14 +100,14 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getSons(JNIEnv * env, job JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getProperty(JNIEnv *env, jobject jas, jobject jname) { simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas); - if (!as) { + if (not as) { jxbt_throw_notbound(env, "as", jas); return nullptr; } const char *name = env->GetStringUTFChars(static_cast(jname), 0); const char* property = MSG_zone_get_property_value(as, name); - if (!property) { + if (not property) { return nullptr; } @@ -126,7 +126,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jo simgrid::s4u::NetZone* as = jnetzone_get_native(env, jas); jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host"); - if (!cls) + if (not cls) return nullptr; std::vector table; @@ -134,7 +134,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jo jtable = env->NewObjectArray(static_cast(table.size()), cls, nullptr); - if (!jtable) { + if (not jtable) { jxbt_throw_jni(env, "Hosts table allocation failed"); return nullptr; } @@ -142,7 +142,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jo int index = 0; for (auto host : table) { jhost = static_cast(host->extension(JAVA_HOST_LEVEL)); - if (!jhost) { + if (not jhost) { jname = env->NewStringUTF(host->cname()); jhost = Java_org_simgrid_msg_Host_getByName(env, cls, jname); diff --git a/src/bindings/java/jmsg_comm.cpp b/src/bindings/java/jmsg_comm.cpp index 320b159fae..8d52bfedf2 100644 --- a/src/bindings/java/jmsg_comm.cpp +++ b/src/bindings/java/jmsg_comm.cpp @@ -78,7 +78,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Comm_test(JNIEnv *env, jobject j return JNI_TRUE; } - if (!comm) { + if (not comm) { jxbt_throw_null(env, bprintf("comm is null")); return JNI_FALSE; } @@ -98,7 +98,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Comm_test(JNIEnv *env, jobject j JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitCompletion(JNIEnv *env, jobject jcomm, jdouble timeout) { msg_comm_t comm = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind); - if (!comm) { + if (not comm) { jxbt_throw_null(env, bprintf("comm is null")); return; } @@ -129,7 +129,7 @@ static msg_comm_t* jarray_to_commArray(JNIEnv *env, jobjectArray jcomms, /* OUT break; comms[i] = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind); - if (!comms[i]) { + if (not comms[i]) { jxbt_throw_null(env, bprintf("comm at rank %d is null", i)); return nullptr; } @@ -142,7 +142,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitAll(JNIEnv *env, jclass cls { int count; msg_comm_t* comms = jarray_to_commArray(env, jcomms, &count); - if (!comms) + if (not comms) return; MSG_comm_waitall(comms, count, static_cast(timeout)); @@ -152,7 +152,7 @@ JNIEXPORT int JNICALL Java_org_simgrid_msg_Comm_waitAny(JNIEnv *env, jclass cls, { int count; msg_comm_t* comms = jarray_to_commArray(env, jcomms, &count); - if (!comms) + if (not comms) return -1; xbt_dynar_t dyn = xbt_dynar_new(sizeof(msg_comm_t),nullptr); for (int i=0; iReleaseStringUTFChars(jname, name); return nullptr; } env->ReleaseStringUTFChars(jname, name); - if (!host->extension(JAVA_HOST_LEVEL)) { /* native host not associated yet with java host */ + if (not host->extension(JAVA_HOST_LEVEL)) { /* native host not associated yet with java host */ /* Instantiate a new java host */ jobject jhost = jhost_new_instance(env); - if (!jhost) { + if (not jhost) { jxbt_throw_jni(env, "java host instantiation failed"); return nullptr; } @@ -81,7 +81,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jcla /* get a global reference to the newly created host */ jhost = jhost_ref(env, jhost); - if (!jhost) { + if (not jhost) { jxbt_throw_jni(env, "new global ref allocation failed"); return nullptr; } @@ -103,13 +103,13 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jc msg_host_t host = MSG_host_self(); - if (!host->extension(JAVA_HOST_LEVEL)) { + if (not host->extension(JAVA_HOST_LEVEL)) { /* the native host not yet associated with the java host instance */ /* instanciate a new java host instance */ jhost = jhost_new_instance(env); - if (!jhost) { + if (not jhost) { jxbt_throw_jni(env, "java host instantiation failed"); return nullptr; } @@ -117,7 +117,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jc /* get a global reference to the newly created host */ jhost = jhost_ref(env, jhost); - if (!jhost) { + if (not jhost) { jxbt_throw_jni(env, "global ref allocation failed"); return nullptr; } @@ -154,7 +154,7 @@ JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getCount(JNIEnv * env, jclass c JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getSpeed(JNIEnv * env, jobject jhost) { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return -1; } @@ -165,7 +165,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getSpeed(JNIEnv * env, jobje JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCoreNumber(JNIEnv * env, jobject jhost) { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return -1; } @@ -176,14 +176,14 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getCoreNumber(JNIEnv * env, JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getProperty(JNIEnv *env, jobject jhost, jobject jname) { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return nullptr; } const char *name = env->GetStringUTFChars((jstring) jname, 0); const char *property = MSG_host_get_property_value(host, name); - if (!property) { + if (not property) { return nullptr; } @@ -198,7 +198,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_setProperty(JNIEnv *env, jobject jhost, jobject jname, jobject jvalue) { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return; } @@ -216,7 +216,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Host_isOn(JNIEnv * env, jobject { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return 0; } @@ -230,7 +230,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getMountedStorage(JNIEn jobject jstorage; jstring jname; - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return 0; } @@ -243,9 +243,9 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getMountedStorage(JNIEn jtable = env->NewObjectArray((jsize) count, cls, nullptr); - if (!jtable) { - jxbt_throw_jni(env, "Storages table allocation failed"); - return nullptr; + if (not jtable) { + jxbt_throw_jni(env, "Storages table allocation failed"); + return nullptr; } xbt_dict_cursor_t cursor=nullptr; @@ -266,7 +266,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getAttachedStorage(JNIE { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return 0; } @@ -290,7 +290,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getStorageContent(JNIEn { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return 0; } @@ -304,12 +304,12 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclas int count = xbt_dynar_length(table); jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host"); - if (!cls) + if (not cls) return nullptr; jobjectArray jtable = env->NewObjectArray((jsize)count, cls, nullptr); - if (!jtable) { + if (not jtable) { jxbt_throw_jni(env, "Hosts table allocation failed"); return nullptr; } @@ -318,7 +318,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclas msg_host_t host = xbt_dynar_get_as(table, index, msg_host_t); jobject jhost = static_cast(host->extension(JAVA_HOST_LEVEL)); - if (!jhost) { + if (not jhost) { jstring jname = env->NewStringUTF(host->cname()); jhost = Java_org_simgrid_msg_Host_getByName(env, cls_arg, jname); } @@ -340,7 +340,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getConsumedEnergy (JNIEnv *e { msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return 0; } diff --git a/src/bindings/java/jmsg_process.cpp b/src/bindings/java/jmsg_process.cpp index 400ab15000..8fcbe02f34 100644 --- a/src/bindings/java/jmsg_process.cpp +++ b/src/bindings/java/jmsg_process.cpp @@ -100,14 +100,14 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jcl { msg_process_t process = MSG_process_from_PID(pid); - if (!process) { + if (not process) { jxbt_throw_process_not_found(env, bprintf("PID = %d",static_cast(pid))); return nullptr; } jobject jprocess = jprocess_from_native(process); - if (!jprocess) { + if (not jprocess) { jxbt_throw_jni(env, "get process failed"); return nullptr; } @@ -118,14 +118,14 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jcl JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname) { msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return nullptr; } const char *name = env->GetStringUTFChars((jstring)jname, 0); const char *property = MSG_process_get_property_value(process, name); - if (!property) + if (not property) return nullptr; jobject jproperty = env->NewStringUTF(property); @@ -138,7 +138,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getCurrentProcess(JNIEnv * env, jclass cls) { jobject jprocess = jprocess_from_native(MSG_process_self()); - if (!jprocess) + if (not jprocess) jxbt_throw_jni(env, xbt_strdup("SIMIX_process_get_jprocess() failed")); return jprocess; @@ -148,7 +148,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_suspend(JNIEnv * env, jobjec { msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return; } @@ -163,7 +163,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume(JNIEnv * env, jobject { msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return; } @@ -177,7 +177,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart (JNIEnv *env, jobject jprocess, jboolean jauto_restart) { msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return; } @@ -189,7 +189,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart (JNIEnv *env, jobjec msg_process_t process = jprocess_to_native(jprocess, env); xbt_ex_t e; - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return; } @@ -206,7 +206,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended(JNIEnv * env { msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return 0; } @@ -250,7 +250,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill(JNIEnv * env, jobject j { /* get the native instances from the java ones */ msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return; } @@ -267,14 +267,14 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate(JNIEnv * env, jobjec { msg_process_t process = jprocess_to_native(jprocess, env); - if (!process) { + if (not process) { jxbt_throw_notbound(env, "process", jprocess); return; } msg_host_t host = jhost_get_native(env, jhost); - if (!host) { + if (not host) { jxbt_throw_notbound(env, "host", jhost); return; } diff --git a/src/bindings/java/jmsg_rngstream.cpp b/src/bindings/java/jmsg_rngstream.cpp index aa1a05013f..0bb54a2a22 100644 --- a/src/bindings/java/jmsg_rngstream.cpp +++ b/src/bindings/java/jmsg_rngstream.cpp @@ -16,7 +16,7 @@ jfieldID jrngstream_bind; RngStream jrngstream_to_native(JNIEnv *env, jobject jrngstream) { RngStream rngstream = (RngStream)(intptr_t)env->GetLongField(jrngstream, jrngstream_bind); - if (!rngstream) { + if (not rngstream) { jxbt_throw_notbound(env, "rngstream", jrngstream); return nullptr; } @@ -67,7 +67,7 @@ Java_org_simgrid_msg_RngStream_setPackageSeed(JNIEnv *env, jobject jrngstream, j JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetStart(JNIEnv *env, jobject jrngstream) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return; RngStream_ResetStartStream(rngstream); @@ -75,7 +75,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetStart(JNIEnv *env, jo JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetStartSubstream(JNIEnv *env, jobject jrngstream) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return; RngStream_ResetStartSubstream(rngstream); @@ -83,7 +83,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetStartSubstream(JNIEnv JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetNextSubstream(JNIEnv *env, jobject jrngstream) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return; RngStream_ResetNextSubstream(rngstream); @@ -91,7 +91,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_resetNextSubstream(JNIEnv JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_setAntithetic(JNIEnv *env, jobject jrngstream, jboolean ja) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return; if (ja == JNI_TRUE) { @@ -108,7 +108,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_RngStream_setSeed(JNIEnv *env, j env->GetIntArrayRegion(jseed, 0, 6, buffer); RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return JNI_FALSE; // The C API expects unsigned long which are wider than int on LP64. @@ -124,7 +124,7 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_RngStream_setSeed(JNIEnv *env, j JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_advanceState(JNIEnv *env, jobject jrngstream, jint e, jint g) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return; RngStream_AdvanceState(rngstream, (long)e, (long)g); @@ -132,7 +132,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_advanceState(JNIEnv *env, JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_RngStream_randU01(JNIEnv *env, jobject jrngstream) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return 0; return (jdouble)RngStream_RandU01(rngstream); @@ -140,7 +140,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_RngStream_randU01(JNIEnv *env, jo JNIEXPORT jint JNICALL Java_org_simgrid_msg_RngStream_randInt(JNIEnv *env, jobject jrngstream, jint i, jint j) { RngStream rngstream = jrngstream_to_native(env, jrngstream); - if (!rngstream) + if (not rngstream) return 0; return (jint)RngStream_RandInt(rngstream, (int)i, (int)j); diff --git a/src/bindings/java/jmsg_storage.cpp b/src/bindings/java/jmsg_storage.cpp index 15bd3fe4ed..a9f5629ed2 100644 --- a/src/bindings/java/jmsg_storage.cpp +++ b/src/bindings/java/jmsg_storage.cpp @@ -63,7 +63,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j const char *name = env->GetStringUTFChars(jname, 0); storage = MSG_storage_get_by_name(name); - if (!storage) { /* invalid name */ + if (not storage) { /* invalid name */ jxbt_throw_storage_not_found(env, name); env->ReleaseStringUTFChars(jname, name); return nullptr; @@ -74,7 +74,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j /* Instantiate a new java storage */ jstorage = jstorage_new_instance(env); - if (!jstorage) { + if (not jstorage) { jxbt_throw_jni(env, "java storage instantiation failed"); return nullptr; } @@ -82,7 +82,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j /* get a global reference to the newly created storage */ jstorage = jstorage_ref(env, jstorage); - if (!jstorage) { + if (not jstorage) { jxbt_throw_jni(env, "new global ref allocation failed"); return nullptr; } @@ -105,7 +105,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getSize(JNIEnv * env,jobject jstorage) { msg_storage_t storage = jstorage_get_native(env, jstorage); - if (!storage) { + if (not storage) { jxbt_throw_notbound(env, "storage", jstorage); return -1; } @@ -116,7 +116,7 @@ JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getSize(JNIEnv * env,jobjec JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getFreeSize(JNIEnv * env,jobject jstorage) { msg_storage_t storage = jstorage_get_native(env, jstorage); - if (!storage) { + if (not storage) { jxbt_throw_notbound(env, "storage", jstorage); return -1; } @@ -127,7 +127,7 @@ JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getFreeSize(JNIEnv * env,jo JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getUsedSize(JNIEnv * env,jobject jstorage) { msg_storage_t storage = jstorage_get_native(env, jstorage); - if (!storage) { + if (not storage) { jxbt_throw_notbound(env, "storage", jstorage); return -1; } @@ -138,14 +138,14 @@ JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getUsedSize(JNIEnv * env,jo JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getProperty(JNIEnv *env, jobject jstorage, jobject jname) { msg_storage_t storage = jstorage_get_native(env, jstorage); - if (!storage) { + if (not storage) { jxbt_throw_notbound(env, "storage", jstorage); return nullptr; } const char *name = env->GetStringUTFChars((jstring) jname, 0); const char *property = MSG_storage_get_property_value(storage, name); - if (!property) { + if (not property) { return nullptr; } jobject jproperty = env->NewStringUTF(property); @@ -159,7 +159,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Storage_setProperty(JNIEnv *env, jobject jstorage, jobject jname, jobject jvalue) { msg_storage_t storage = jstorage_get_native(env, jstorage); - if (!storage) { + if (not storage) { jxbt_throw_notbound(env, "storage", jstorage); return; } @@ -177,12 +177,12 @@ Java_org_simgrid_msg_Storage_setProperty(JNIEnv *env, jobject jstorage, jobject JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getHost(JNIEnv * env,jobject jstorage) { msg_storage_t storage = jstorage_get_native(env, jstorage); - if (!storage) { + if (not storage) { jxbt_throw_notbound(env, "storage", jstorage); return nullptr; } const char *host_name = MSG_storage_get_host(storage); - if (!host_name) { + if (not host_name) { return nullptr; } jobject jhost_name = env->NewStringUTF(host_name); @@ -203,13 +203,13 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Storage_all(JNIEnv * env, jc jclass cls = jxbt_get_class(env, "org/simgrid/msg/Storage"); - if (!cls) { + if (not cls) { return nullptr; } jtable = env->NewObjectArray((jsize) count, cls, nullptr); - if (!jtable) { + if (not jtable) { jxbt_throw_jni(env, "Storages table allocation failed"); return nullptr; } diff --git a/src/bindings/java/jmsg_task.cpp b/src/bindings/java/jmsg_task.cpp index d6151845eb..47dfe47f93 100644 --- a/src/bindings/java/jmsg_task.cpp +++ b/src/bindings/java/jmsg_task.cpp @@ -105,7 +105,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_cancel(JNIEnv * env, jobject jt { msg_task_t ptask = jtask_to_native(jtask, env); - if (!ptask) { + if (not ptask) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -119,7 +119,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_execute(JNIEnv * env, jobject j { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -136,7 +136,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setBound(JNIEnv * env, jobject { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -146,7 +146,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setBound(JNIEnv * env, jobject JNIEXPORT jstring JNICALL Java_org_simgrid_msg_Task_getName(JNIEnv * env, jobject jtask) { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return nullptr; } @@ -159,7 +159,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSender(JNIEnv * env, jobj msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return nullptr; } @@ -176,7 +176,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSource(JNIEnv * env, jobj msg_host_t host; msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return nullptr; } @@ -185,7 +185,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSource(JNIEnv * env, jobj if (host == nullptr) { return nullptr; } - if (!host->extension(JAVA_HOST_LEVEL)) { + if (not host->extension(JAVA_HOST_LEVEL)) { jxbt_throw_jni(env, "MSG_task_get_source() failed"); return nullptr; } @@ -197,7 +197,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Task_getFlopsAmount(JNIEnv * env, { msg_task_t ptask = jtask_to_native(jtask, env); - if (!ptask) { + if (not ptask) { jxbt_throw_notbound(env, "task", jtask); return -1; } @@ -207,7 +207,7 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Task_getFlopsAmount(JNIEnv * env, JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setName(JNIEnv *env, jobject jtask, jobject jname) { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -223,7 +223,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setPriority(JNIEnv * env, jobje { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -234,7 +234,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setFlopsAmount (JNIEnv *env, jo { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -245,7 +245,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setBytesAmount (JNIEnv *env, jo { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -257,7 +257,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_sendBounded(JNIEnv * env,jobjec jdouble jtimeout,jdouble maxrate) { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -299,7 +299,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receive(JNIEnv* env, jclass JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecv(JNIEnv * env, jclass cls, jstring jmailbox) { jclass comm_class = env->FindClass("org/simgrid/msg/Comm"); - if (!comm_class) + if (not comm_class) return nullptr; //pointer to store the task object pointer. @@ -308,7 +308,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecv(JNIEnv * env, jclass c /* There should be a cache here */ jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor); - if (!jcomm) { + if (not jcomm) { jxbt_throw_jni(env, "Can't create a Comm object."); return nullptr; } @@ -354,14 +354,14 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecvBounded(JNIEnv * env, j jdouble rate) { jclass comm_class = env->FindClass("org/simgrid/msg/Comm"); - if (!comm_class) + if (not comm_class) return nullptr; // pointer to store the task object pointer. msg_task_t* task = xbt_new0(msg_task_t, 1); jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor); - if (!jcomm) { + if (not jcomm) { jxbt_throw_jni(env, "Can't create a Comm object."); return nullptr; } @@ -383,14 +383,15 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isend(JNIEnv *env, jobject j jclass comm_class = env->FindClass("org/simgrid/msg/Comm"); - if (!comm_class) return nullptr; + if (not comm_class) + return nullptr; jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor); const char* mailbox = env->GetStringUTFChars(jmailbox, 0); msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { env->ReleaseStringUTFChars(jmailbox, mailbox); env->DeleteLocalRef(jcomm); jxbt_throw_notbound(env, "task", jtask); @@ -418,7 +419,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isendBounded(JNIEnv *env, jo const char *mailbox; jclass comm_class = env->FindClass("org/simgrid/msg/Comm"); - if (!comm_class) + if (not comm_class) return nullptr; jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor); @@ -426,7 +427,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isendBounded(JNIEnv *env, jo task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { env->ReleaseStringUTFChars(jmailbox, mailbox); env->DeleteLocalRef(jcomm); jxbt_throw_notbound(env, "task", jtask); @@ -449,7 +450,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_nativeFinalize(JNIEnv * env, jo { msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { jxbt_throw_notbound(env, "task", jtask); return; } @@ -474,7 +475,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_dsend(JNIEnv * env, jobject jta msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { env->ReleaseStringUTFChars(jalias, alias); jxbt_throw_notbound(env, "task", jtask); return; @@ -494,7 +495,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_dsendBounded(JNIEnv * env, jobj msg_task_t task = jtask_to_native(jtask, env); - if (!task) { + if (not task) { env->ReleaseStringUTFChars(jalias, alias); jxbt_throw_notbound(env, "task", jtask); return; diff --git a/src/bindings/java/jmsg_vm.cpp b/src/bindings/java/jmsg_vm.cpp index 307b8f3db6..fc5da71197 100644 --- a/src/bindings/java/jmsg_vm.cpp +++ b/src/bindings/java/jmsg_vm.cpp @@ -101,11 +101,11 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_VM_all(JNIEnv* env, jclass c int count = vms.size(); jclass cls = jxbt_get_class(env, "org/simgrid/msg/VM"); - if (!cls) + if (not cls) return nullptr; jobjectArray jtable = env->NewObjectArray((jsize)count, cls, nullptr); - if (!jtable) { + if (not jtable) { jxbt_throw_jni(env, "Hosts table allocation failed"); return nullptr; } @@ -180,7 +180,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_VM_getVMByName(JNIEnv* env, jclas /* get the VM by name (VMs are just special hosts, unfortunately) */ msg_host_t host = MSG_host_by_name(name); - if (!host) { /* invalid name */ + if (not host) { /* invalid name */ jxbt_throw_host_not_found(env, name); env->ReleaseStringUTFChars(jname, name); return nullptr; diff --git a/src/bindings/java/jxbt_utilities.cpp b/src/bindings/java/jxbt_utilities.cpp index c735ff410c..128f0770a5 100644 --- a/src/bindings/java/jxbt_utilities.cpp +++ b/src/bindings/java/jxbt_utilities.cpp @@ -16,7 +16,7 @@ jclass jxbt_get_class(JNIEnv * env, const char *name) { jclass cls = env->FindClass(name); - if (!cls) { + if (not cls) { jxbt_throw_jni(env, std::string("Class ") + name + " not found"); return nullptr; } @@ -28,11 +28,11 @@ jmethodID jxbt_get_jmethod(JNIEnv * env, jclass cls, const char *name, const cha { jmethodID id; - if (!cls) + if (not cls) return 0; id = env->GetMethodID(cls, name, signature); - if (!id) { + if (not id) { jmethodID tostr_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;"); jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, nullptr); @@ -51,11 +51,11 @@ jmethodID jxbt_get_static_jmethod(JNIEnv * env, jclass cls, const char *name, co { jmethodID id; - if (!cls) + if (not cls) return 0; id = env->GetStaticMethodID(cls, name, signature); - if (!id) { + if (not id) { jmethodID tostr_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;"); jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, nullptr); const char *classname = env->GetStringUTFChars(jclassname, 0); @@ -75,12 +75,12 @@ jmethodID jxbt_get_static_smethod(JNIEnv * env, const char *classname, const cha jmethodID id; cls = jxbt_get_class(env, classname); - if (!cls) + if (not cls) return 0; id = env->GetStaticMethodID(cls, name, signature); - if (!id) { + if (not id) { jxbt_throw_jni(env, std::string("Cannot find static method") + name + "(" + signature + ") in " + classname); return 0; } @@ -93,12 +93,12 @@ jmethodID jxbt_get_smethod(JNIEnv * env, const char *classname, const char *name jmethodID id; cls = jxbt_get_class(env, classname); - if (!cls) + if (not cls) return 0; id = env->GetMethodID(cls, name, signature); - if (!id) { + if (not id) { jxbt_throw_jni(env, std::string("Cannot find method") + name + "(" + signature + ") in " + classname); return 0; } @@ -109,12 +109,12 @@ jfieldID jxbt_get_jfield(JNIEnv * env, jclass cls, const char *name, const char { jfieldID id; - if (!cls) + if (not cls) return 0; id = env->GetFieldID(cls, name, signature); - if (!id) { + if (not id) { jmethodID getname_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;"); jstring jclassname = (jstring) env->CallObjectMethod(cls, getname_id, nullptr); const char *classname = env->GetStringUTFChars(jclassname, 0); @@ -134,12 +134,12 @@ jfieldID jxbt_get_sfield(JNIEnv * env, const char *classname, const char *name, jclass cls = jxbt_get_class(env, classname); jfieldID id; - if (!cls) + if (not cls) return 0; id = env->GetFieldID(cls, name, signature); - if (!id) { + if (not id) { jxbt_throw_jni(env, std::string("Cannot find field") + signature + " " + name + " in " + classname); return 0; } diff --git a/src/bindings/lua/lua_debug.cpp b/src/bindings/lua/lua_debug.cpp index 79b1bc5c06..df54f3f135 100644 --- a/src/bindings/lua/lua_debug.cpp +++ b/src/bindings/lua/lua_debug.cpp @@ -198,7 +198,7 @@ void* sglua_checkudata_debug(lua_State* L, int ud, const char* tname) XBT_DEBUG("Checking the task's metatable: expected %p, found %p", correct_mt, actual_mt); sglua_stack_dump(L, "my_checkudata: "); - if (p == nullptr || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2)) + if (p == nullptr || not lua_getmetatable(L, ud) || not lua_rawequal(L, -1, -2)) XBT_ERROR("Error: Userdata is nullptr, couldn't find metatable or top of stack does not equal element below it."); lua_pop(L, 2); return p; diff --git a/src/bindings/lua/lua_host.cpp b/src/bindings/lua/lua_host.cpp index 71484a4251..4d4eac910a 100644 --- a/src/bindings/lua/lua_host.cpp +++ b/src/bindings/lua/lua_host.cpp @@ -34,7 +34,7 @@ sg_host_t sglua_check_host(lua_State * L, int index) if (pi == nullptr) XBT_ERROR("luaL_checkudata() returned nullptr"); sg_host_t ht = *pi; - if (!ht) + if (not ht) luaL_error(L, "null Host"); return ht; } diff --git a/src/bindings/lua/lua_platf.cpp b/src/bindings/lua/lua_platf.cpp index dea2bab15a..3f9a36dc07 100644 --- a/src/bindings/lua/lua_platf.cpp +++ b/src/bindings/lua/lua_platf.cpp @@ -94,9 +94,9 @@ int console_add_backbone(lua_State *L) { lua_pushstring(L, "sharing_policy"); type = lua_gettable(L, -2); const char* policy = lua_tostring(L, -1); - if (policy && !strcmp(policy,"FULLDUPLEX")) { + if (policy && not strcmp(policy, "FULLDUPLEX")) { link.policy = SURF_LINK_FULLDUPLEX; - } else if (policy && !strcmp(policy,"FATPIPE")) { + } else if (policy && not strcmp(policy, "FATPIPE")) { link.policy = SURF_LINK_FATPIPE; } else { link.policy = SURF_LINK_SHARED; @@ -173,8 +173,8 @@ int console_add_host(lua_State *L) { // get core lua_pushstring(L, "core"); lua_gettable(L, -2); - if(!lua_isnumber(L,-1)) - host.core_amount = 1;// Default value + if (not lua_isnumber(L, -1)) + host.core_amount = 1; // Default value else host.core_amount = lua_tonumber(L, -1); if (host.core_amount == 0) @@ -270,9 +270,9 @@ int console_add_link(lua_State *L) { lua_gettable(L, -2); policy = lua_tostring(L, -1); lua_pop(L, 1); - if (policy && !strcmp(policy,"FULLDUPLEX")) { + if (policy && not strcmp(policy, "FULLDUPLEX")) { link.policy = SURF_LINK_FULLDUPLEX; - } else if (policy && !strcmp(policy,"FATPIPE")) { + } else if (policy && not strcmp(policy, "FATPIPE")) { link.policy = SURF_LINK_FATPIPE; } else { link.policy = SURF_LINK_SHARED; @@ -473,13 +473,20 @@ int console_AS_open(lua_State *L) { lua_pop(L, 1); int mode_int = A_surfxml_AS_routing_None; - if(!strcmp(mode,"Full")) mode_int = A_surfxml_AS_routing_Full; - else if(!strcmp(mode,"Floyd")) mode_int = A_surfxml_AS_routing_Floyd; - else if(!strcmp(mode,"Dijkstra")) mode_int = A_surfxml_AS_routing_Dijkstra; - else if(!strcmp(mode,"DijkstraCache")) mode_int = A_surfxml_AS_routing_DijkstraCache; - else if(!strcmp(mode,"Vivaldi")) mode_int = A_surfxml_AS_routing_Vivaldi; - else if(!strcmp(mode,"Cluster")) mode_int = A_surfxml_AS_routing_Cluster; - else if(!strcmp(mode,"none")) mode_int = A_surfxml_AS_routing_None; + if (not strcmp(mode, "Full")) + mode_int = A_surfxml_AS_routing_Full; + else if (not strcmp(mode, "Floyd")) + mode_int = A_surfxml_AS_routing_Floyd; + else if (not strcmp(mode, "Dijkstra")) + mode_int = A_surfxml_AS_routing_Dijkstra; + else if (not strcmp(mode, "DijkstraCache")) + mode_int = A_surfxml_AS_routing_DijkstraCache; + else if (not strcmp(mode, "Vivaldi")) + mode_int = A_surfxml_AS_routing_Vivaldi; + else if (not strcmp(mode, "Cluster")) + mode_int = A_surfxml_AS_routing_Cluster; + else if (not strcmp(mode, "none")) + mode_int = A_surfxml_AS_routing_None; else xbt_die("Don't have the model name '%s'",mode); s_sg_platf_AS_cbarg_t AS; diff --git a/src/instr/instr_config.cpp b/src/instr/instr_config.cpp index 8b923a69b1..e6eb6f5182 100644 --- a/src/instr/instr_config.cpp +++ b/src/instr/instr_config.cpp @@ -105,9 +105,9 @@ int TRACE_start() /* open the trace file(s) */ const char* format = xbt_cfg_get_string(OPT_TRACING_FORMAT); XBT_DEBUG("Tracing format %s\n", format); - if(!strcmp(format, "Paje")){ + if (not strcmp(format, "Paje")) { TRACE_paje_start(); - }else if (!strcmp(format, "TI")){ + } else if (not strcmp(format, "TI")) { instr_fmt_type = instr_fmt_TI; TRACE_TI_start(); }else{ @@ -134,7 +134,7 @@ int TRACE_start() int TRACE_end() { int retval; - if (!trace_active) { + if (not trace_active) { retval = 1; } else { retval = 0; @@ -161,9 +161,9 @@ int TRACE_end() /* close the trace files */ const char* format = xbt_cfg_get_string(OPT_TRACING_FORMAT); XBT_DEBUG("Tracing format %s\n", format); - if(!strcmp(format, "Paje")){ + if (not strcmp(format, "Paje")) { TRACE_paje_end(); - }else if (!strcmp(format, "TI")){ + } else if (not strcmp(format, "TI")) { TRACE_TI_end(); }else{ xbt_die("Unknown trace format :%s ", format); @@ -605,7 +605,7 @@ static int previous_trace_state = -1; void instr_pause_tracing () { previous_trace_state = trace_enabled; - if (!TRACE_is_enabled()){ + if (not TRACE_is_enabled()) { XBT_DEBUG ("Tracing is already paused, therefore do nothing."); }else{ XBT_DEBUG ("Tracing is being paused."); diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index 7946c2be86..dbefe457ee 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -30,7 +30,7 @@ extern xbt_dict_t trivaEdgeTypes; static xbt_dynar_t instr_dict_to_dynar (xbt_dict_t filter) { - if (!TRACE_is_enabled() || !TRACE_needs_platform()) + if (not TRACE_is_enabled() || not TRACE_needs_platform()) return nullptr; xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref); @@ -81,7 +81,7 @@ void TRACE_category(const char *category) void TRACE_category_with_color (const char *category, const char *color) { /* safe switches. tracing has to be activated and if platform is not traced, we can't deal with categories */ - if (!TRACE_is_enabled() || !TRACE_needs_platform()) + if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; if (!(TRACE_categorized() && category != nullptr)) @@ -95,7 +95,7 @@ void TRACE_category_with_color (const char *category, const char *color) //define final_color char final_color[INSTR_DEFAULT_STR_SIZE]; - if (!color){ + if (not color) { //generate a random color double red = drand48(); double green = drand48(); @@ -125,7 +125,7 @@ void TRACE_category_with_color (const char *category, const char *color) */ xbt_dynar_t TRACE_get_categories () { - if (!TRACE_is_enabled() || !TRACE_categorized()) + if (not TRACE_is_enabled() || not TRACE_categorized()) return nullptr; return instr_dict_to_dynar (created_categories); @@ -144,10 +144,10 @@ xbt_dynar_t TRACE_get_categories () void TRACE_declare_mark(const char *mark_type) { /* safe switchs. tracing has to be activated and if platform is not traced, we can't deal with marks */ - if (!TRACE_is_enabled() || !TRACE_needs_platform()) + if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; - if (!mark_type) + if (not mark_type) THROWF (tracing_error, 1, "mark_type is nullptr"); //check if mark_type is already declared @@ -178,21 +178,21 @@ void TRACE_declare_mark(const char *mark_type) void TRACE_declare_mark_value_with_color (const char *mark_type, const char *mark_value, const char *mark_color) { /* safe switches. tracing has to be activated and if platform is not traced, we can't deal with marks */ - if (!TRACE_is_enabled() || !TRACE_needs_platform()) + if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; - if (!mark_type) + if (not mark_type) THROWF (tracing_error, 1, "mark_type is nullptr"); - if (!mark_value) + if (not mark_value) THROWF (tracing_error, 1, "mark_value is nullptr"); type_t type = PJ_type_get (mark_type, PJ_type_get_root()); - if (!type){ + if (not type) { THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type); } char white[INSTR_DEFAULT_STR_SIZE] = "1.0 1.0 1.0"; - if (!mark_color) + if (not mark_color) mark_color = white; XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color); @@ -233,17 +233,17 @@ void TRACE_declare_mark_value (const char *mark_type, const char *mark_value) void TRACE_mark(const char *mark_type, const char *mark_value) { /* safe switches. tracing has to be activated and if platform is not traced, we can't deal with marks */ - if (!TRACE_is_enabled() || !TRACE_needs_platform()) + if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; - if (!mark_type) + if (not mark_type) THROWF (tracing_error, 1, "mark_type is nullptr"); - if (!mark_value) + if (not mark_value) THROWF (tracing_error, 1, "mark_value is nullptr"); //check if mark_type is already declared type_t type = PJ_type_get (mark_type, PJ_type_get_root()); - if (!type){ + if (not type) { THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type); } @@ -261,7 +261,7 @@ void TRACE_mark(const char *mark_type, const char *mark_value) */ xbt_dynar_t TRACE_get_marks () { - if (!TRACE_is_enabled()) + if (not TRACE_is_enabled()) return nullptr; return instr_dict_to_dynar (declared_marks); @@ -271,13 +271,13 @@ static void instr_user_variable(double time, const char *resource, const char *v double value, InstrUserVariable what, const char *color, xbt_dict_t filter) { /* safe switches. tracing has to be activated and if platform is not traced, we don't allow user variables */ - if (!TRACE_is_enabled() || !TRACE_needs_platform()) + if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; //check if variable is already declared char *created = (char*)xbt_dict_get_or_null(filter, variable); if (what == INSTR_US_DECLARE){ - if (!created) { // not declared yet + if (not created) { // not declared yet xbt_dict_set (filter, variable, xbt_strdup("1"), nullptr); instr_new_user_variable_type (father_type, variable, color); } @@ -309,11 +309,11 @@ static void instr_user_srcdst_variable(double time, const char *src, const char const char *father_type, double value, InstrUserVariable what) { sg_netpoint_t src_elm = sg_netpoint_by_name_or_null(src); - if(!src_elm) + if (not src_elm) xbt_die("Element '%s' not found!",src); sg_netpoint_t dst_elm = sg_netpoint_by_name_or_null(dst); - if(!dst_elm) + if (not dst_elm) xbt_die("Element '%s' not found!",dst); std::vector route; @@ -336,7 +336,7 @@ static void instr_user_srcdst_variable(double time, const char *src, const char int TRACE_platform_graph_export_graphviz (const char *filename) { /* returns 1 if successful, 0 otherwise */ - if (!TRACE_is_enabled()) + if (not TRACE_is_enabled()) return 0; xbt_graph_t g = instr_routing_platform_graph(); if (g == nullptr) diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index 9b50d75e26..f024629ae9 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -203,7 +203,7 @@ void PJ_container_free (container_t container) TRACE_paje_dump_buffer(1); //trace my destruction - if (!TRACE_disable_destroy() && container != PJ_container_get_root()){ + if (not TRACE_disable_destroy() && container != PJ_container_get_root()) { //do not trace the container destruction if user requests //or if the container is root new DestroyContainerEvent(container); @@ -245,7 +245,7 @@ void PJ_container_free_all () rootContainer = nullptr; //checks - if (!xbt_dict_is_empty(allContainers)){ + if (not xbt_dict_is_empty(allContainers)) { THROWF(tracing_error, 0, "some containers still present even after destroying all of them"); } } diff --git a/src/instr/instr_paje_trace.cpp b/src/instr/instr_paje_trace.cpp index 54473aca6f..c574f803f0 100644 --- a/src/instr/instr_paje_trace.cpp +++ b/src/instr/instr_paje_trace.cpp @@ -44,18 +44,20 @@ void buffer_debug(std::vector *buf); void dump_comment (const char *comment) { - if (!strlen(comment)) return; + if (not strlen(comment)) + return; fprintf (tracing_file, "# %s\n", comment); } void dump_comment_file (const char *filename) { - if (!strlen(filename)) return; + if (not strlen(filename)) + return; FILE *file = fopen (filename, "r"); - if (!file){ + if (not file) { THROWF (system_error, 1, "Comment file %s could not be opened for reading.", filename); } - while (!feof(file)){ + while (not feof(file)) { char c; c = fgetc(file); if (feof(file)) break; @@ -74,7 +76,8 @@ double TRACE_last_timestamp_to_dump = 0; //dumps the trace file until the timestamp TRACE_last_timestamp_to_dump void TRACE_paje_dump_buffer (int force) { - if (!TRACE_is_enabled()) return; + if (not TRACE_is_enabled()) + return; XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump); if (force){ for (auto event : buffer){ @@ -429,9 +432,9 @@ void CreateContainerEvent::print() { prefix = xbt_os_time(); } - if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || ti_unique_file == nullptr) { - char *folder_name = bprintf("%s_files", TRACE_get_filename()); - char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, container->name); + if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || ti_unique_file == nullptr) { + char* folder_name = bprintf("%s_files", TRACE_get_filename()); + char* filename = bprintf("%s/%f_%s.txt", folder_name, prefix, container->name); #ifdef WIN32 _mkdir(folder_name); #else @@ -473,14 +476,14 @@ void DestroyContainerEvent::print() { print_row(); } else if (instr_fmt_type == instr_fmt_TI) { - if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file")|| xbt_dict_length(tracing_files) == 1) { - FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, container->name); - fclose(f); - } - xbt_dict_remove(tracing_files, container->name); - } else { - THROW_IMPOSSIBLE; - } + if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || xbt_dict_length(tracing_files) == 1) { + FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, container->name); + fclose(f); + } + xbt_dict_remove(tracing_files, container->name); + } else { + THROW_IMPOSSIBLE; + } } SetVariableEvent::SetVariableEvent (double timestamp, container_t container, type_t type, double value) diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index c9baee5117..acb89e3c47 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -156,7 +156,7 @@ type_t PJ_type_variable_new (const char *name, const char *color, type_t father) type_t ret = nullptr; char white[INSTR_DEFAULT_STR_SIZE] = "1 1 1"; - if (!color){ + if (not color) { ret = newType (name, name, white, TYPE_VARIABLE, father); }else{ ret = newType (name, name, color, TYPE_VARIABLE, father); diff --git a/src/instr/instr_resource_utilization.cpp b/src/instr/instr_resource_utilization.cpp index 0cfed5e590..3135882228 100644 --- a/src/instr/instr_resource_utilization.cpp +++ b/src/instr/instr_resource_utilization.cpp @@ -26,7 +26,7 @@ static void __TRACE_surf_check_variable_set_to_zero(double now, const char *vari snprintf (key, n, "%s%s", resource, variable); // check if key exists: if it doesn't, set the variable to zero and mark this in the dict - if (!xbt_dict_get_or_null(platform_variables, key)) { + if (not xbt_dict_get_or_null(platform_variables, key)) { container_t container = PJ_container_get (resource); type_t type = PJ_type_get (variable, container->type); new SetVariableEvent (now, container, type, 0); @@ -46,9 +46,9 @@ static void instr_event (double now, double delta, type_t variable, container_t void TRACE_surf_link_set_utilization(const char *resource, const char *category, double value, double now, double delta) { //only trace link utilization if link is known by tracing mechanism - if (!PJ_container_get_or_null(resource)) + if (not PJ_container_get_or_null(resource)) return; - if (!value) + if (not value) return; //trace uncategorized link utilization @@ -61,7 +61,7 @@ void TRACE_surf_link_set_utilization(const char *resource, const char *category, //trace categorized utilization if (TRACE_categorized()){ - if (!category) + if (not category) return; //variable of this category starts by 'b', because we have a link here char category_type[INSTR_DEFAULT_STR_SIZE]; @@ -78,7 +78,7 @@ void TRACE_surf_host_set_utilization(const char *resource, const char *category, { //only trace host utilization if host is known by tracing mechanism container_t container = PJ_container_get_or_null(resource); - if (!container || !value) + if (not container || not value) return; //trace uncategorized host utilization @@ -90,7 +90,7 @@ void TRACE_surf_host_set_utilization(const char *resource, const char *category, //trace categorized utilization if (TRACE_categorized()){ - if (!category) + if (not category) return; //variable of this category starts by 'p', because we have a host here char category_type[INSTR_DEFAULT_STR_SIZE]; diff --git a/src/instr/jedule/jedule.cpp b/src/instr/jedule/jedule.cpp index 86dbae5e65..4f7841fe43 100644 --- a/src/instr/jedule/jedule.cpp +++ b/src/instr/jedule/jedule.cpp @@ -27,10 +27,10 @@ void Jedule::addMetaInfo(char *key, char *value) { } void Jedule::writeOutput(FILE *file) { - if (!this->event_set.empty()){ + if (not this->event_set.empty()) { fprintf(file, "\n"); - if (!this->meta_info.empty()){ + if (not this->meta_info.empty()) { fprintf(file, " \n"); for (auto elm: this->meta_info) fprintf(file, " \n",elm.first,elm.second); diff --git a/src/instr/jedule/jedule_events.cpp b/src/instr/jedule/jedule_events.cpp index 95a591b042..afe12f3cac 100644 --- a/src/instr/jedule/jedule_events.cpp +++ b/src/instr/jedule/jedule_events.cpp @@ -20,7 +20,7 @@ Event::Event(std::string name, double start_time, double end_time, std::string t Event::~Event() { - if (!this->resource_subsets->empty()){ + if (not this->resource_subsets->empty()) { for (auto subset: *this->resource_subsets) delete subset; delete this->resource_subsets; @@ -51,7 +51,7 @@ void Event::print(FILE *jed_file) fprintf(jed_file, " \n", this->end_time); fprintf(jed_file, " \n", this->type.c_str()); - xbt_assert(!this->resource_subsets-> empty()); + xbt_assert(not this->resource_subsets->empty()); fprintf(jed_file, " \n"); for (auto subset: *this->resource_subsets) { fprintf(jed_file, "