From: Christian Heinrich Date: Wed, 8 Jun 2016 21:20:59 +0000 (+0200) Subject: [BINDINGS] NULL -> nullptr substitution X-Git-Tag: v3_14~1025 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d5cf915bd09762c921e587f376420993f216a239 [BINDINGS] NULL -> nullptr substitution I used the following command: (the '**' means recursion in ZSH) sed -i -e 's/\([^_]\s*\)NULL/\1nullptr/g' src/**/*.cpp We check for the underscore to avoid replacing MPI_*_NULL --- diff --git a/src/bindings/java/JavaContext.cpp b/src/bindings/java/JavaContext.cpp index 54b394fdda..cbe65b1e34 100644 --- a/src/bindings/java/JavaContext.cpp +++ b/src/bindings/java/JavaContext.cpp @@ -107,7 +107,7 @@ void* JavaContext::wrapper(void *data) JNIEnv *env; XBT_ATTRIB_UNUSED jint error = - __java_vm->AttachCurrentThread((void **) &env, NULL); + __java_vm->AttachCurrentThread((void **) &env, nullptr); xbt_assert((error == JNI_OK), "The thread could not be attached to the JVM"); context->jenv = get_current_thread_env(); //Wait for the first scheduling round to happen. @@ -143,7 +143,7 @@ void JavaContext::stop() XBT_ATTRIB_UNUSED jint error = __java_vm->DetachCurrentThread(); xbt_assert((error == JNI_OK), "The thread couldn't be detached."); xbt_os_sem_release(this->end); - xbt_os_thread_exit(NULL); + xbt_os_thread_exit(nullptr); } } diff --git a/src/bindings/java/jmsg.cpp b/src/bindings/java/jmsg.cpp index eeb39838df..71035a32cb 100644 --- a/src/bindings/java/jmsg.cpp +++ b/src/bindings/java/jmsg.cpp @@ -37,7 +37,7 @@ int JAVA_STORAGE_LEVEL = -1; XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg); -JavaVM *__java_vm = NULL; +JavaVM *__java_vm = nullptr; JavaVM *get_java_VM(void) { @@ -48,23 +48,23 @@ JNIEnv *get_current_thread_env(void) { JNIEnv *env; - __java_vm->AttachCurrentThread((void **) &env, NULL); + __java_vm->AttachCurrentThread((void **) &env, nullptr); return env; } void jmsg_throw_status(JNIEnv *env, msg_error_t status) { switch (status) { case MSG_TIMEOUT: - jxbt_throw_time_out_failure(env,NULL); + jxbt_throw_time_out_failure(env,nullptr); break; case MSG_TRANSFER_FAILURE: - jxbt_throw_transfer_failure(env,NULL); + jxbt_throw_transfer_failure(env,nullptr); break; case MSG_HOST_FAILURE: - jxbt_throw_host_failure(env,NULL); + jxbt_throw_host_failure(env,nullptr); break; case MSG_TASK_CANCELED: - jxbt_throw_task_cancelled(env,NULL); + jxbt_throw_task_cancelled(env,nullptr); break; default: jxbt_throw_native(env,xbt_strdup("undefined message failed " @@ -91,7 +91,7 @@ static void __JAVA_storage_priv_free(void *storage) JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs) { - char **argv = NULL; + char **argv = nullptr; int index; int argc = 0; jstring jval; @@ -123,7 +123,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, j argv[index + 1] = xbt_strdup(tmp); env->ReleaseStringUTFChars(jval, tmp); } - argv[argc] = NULL; + argv[argc] = nullptr; MSG_init(&argc, argv); @@ -184,12 +184,12 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNI jobject jas = jas_new_instance(env); if (!jas) { jxbt_throw_jni(env, "java As instantiation failed"); - return NULL; + return nullptr; } jas = jas_ref(env, jas); if (!jas) { jxbt_throw_jni(env, "new global ref allocation failed"); - return NULL; + return nullptr; } jas_bind(jas, as, env); @@ -282,9 +282,9 @@ static int java_main(int argc, char *argv[]) jclass class_Process = env->FindClass(argv[0]); xbt_str_subst(argv[0],'/','.',0); //Retrieve the methodID for the constructor - xbt_assert((class_Process != NULL), "Class not found (%s). The deployment file must use the fully qualified class name, including the package. The case is important.", argv[0]); + xbt_assert((class_Process != nullptr), "Class not found (%s). The deployment file must use the fully qualified class name, including the package. The case is important.", argv[0]); jmethodID constructor_Process = env->GetMethodID(class_Process, "", "(Lorg/simgrid/msg/Host;Ljava/lang/String;[Ljava/lang/String;)V"); - xbt_assert((constructor_Process != NULL), "Constructor not found for class %s. Is there a (Host, String ,String[]) constructor in your class ?", argv[0]); + xbt_assert((constructor_Process != nullptr), "Constructor not found for class %s. Is there a (Host, String ,String[]) constructor in your class ?", argv[0]); //Retrieve the name of the process. jstring jname = env->NewStringUTF(argv[0]); @@ -297,10 +297,10 @@ static int java_main(int argc, char *argv[]) env->SetObjectArrayElement(args,i - 1, env->NewStringUTF(argv[i])); //Retrieve the host for the process. jstring jhostName = env->NewStringUTF(MSG_host_get_name(MSG_host_self())); - jobject jhost = Java_org_simgrid_msg_Host_getByName(env, NULL, jhostName); + jobject jhost = Java_org_simgrid_msg_Host_getByName(env, nullptr, jhostName); //creates the process jobject jprocess = env->NewObject(class_Process, constructor_Process, jhost, jname, args); - xbt_assert((jprocess != NULL), "Process allocation failed."); + xbt_assert((jprocess != nullptr), "Process allocation failed."); jprocess = env->NewGlobalRef(jprocess); //bind the process to the context msg_process_t process = MSG_process_self(); diff --git a/src/bindings/java/jmsg_as.cpp b/src/bindings/java/jmsg_as.cpp index b2fe858b0a..df66f45f33 100644 --- a/src/bindings/java/jmsg_as.cpp +++ b/src/bindings/java/jmsg_as.cpp @@ -66,29 +66,29 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getSons(JNIEnv * env, job jclass cls = env->FindClass("org/simgrid/msg/As"); if (!cls) { - return NULL; + return nullptr; } - jtable = env->NewObjectArray((jsize) count, cls, NULL); + jtable = env->NewObjectArray((jsize) count, cls, nullptr); if (!jtable) { jxbt_throw_jni(env, "Hosts table allocation failed"); - return NULL; + return nullptr; } - xbt_dict_cursor_t cursor=NULL; + xbt_dict_cursor_t cursor=nullptr; char *key; xbt_dict_foreach(dict,cursor,key,tmp_as) { tmp_jas = jas_new_instance(env); if (!tmp_jas) { jxbt_throw_jni(env, "java As instantiation failed"); - return NULL; + return nullptr; } tmp_jas = jas_ref(env, tmp_jas); if (!tmp_jas) { jxbt_throw_jni(env, "new global ref allocation failed"); - return NULL; + return nullptr; } jas_bind(tmp_jas, tmp_as, env); @@ -103,13 +103,13 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getProperty(JNIEnv *env, jobje if (!as) { jxbt_throw_notbound(env, "as", jas); - return NULL; + return nullptr; } const char *name = env->GetStringUTFChars((jstring) jname, 0); const char *property = MSG_environment_as_get_property_value(as, name); if (!property) { - return NULL; + return nullptr; } jobject jproperty = env->NewStringUTF(property); @@ -134,14 +134,14 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jo jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host"); if (!cls) { - return NULL; + return nullptr; } - jtable = env->NewObjectArray((jsize) count, cls, NULL); + jtable = env->NewObjectArray((jsize) count, cls, nullptr); if (!jtable) { jxbt_throw_jni(env, "Hosts table allocation failed"); - return NULL; + return nullptr; } for (index = 0; index < count; index++) { diff --git a/src/bindings/java/jmsg_comm.cpp b/src/bindings/java/jmsg_comm.cpp index 387768f416..e2589398bf 100644 --- a/src/bindings/java/jmsg_comm.cpp +++ b/src/bindings/java/jmsg_comm.cpp @@ -26,10 +26,10 @@ void jcomm_bind_task(JNIEnv *env, jobject jcomm) { if (jreceiving == JNI_TRUE) { //bind the task object. msg_task_t task = MSG_comm_get_task(comm); - xbt_assert(task != NULL, "Task is NULL"); + xbt_assert(task != nullptr, "Task is nullptr"); jobject jtask_global = (jobject) MSG_task_get_data(task); //case where the data has already been retrieved - if (jtask_global == NULL) { + if (jtask_global == nullptr) { return; } @@ -39,7 +39,7 @@ void jcomm_bind_task(JNIEnv *env, jobject jcomm) { env->SetObjectField(jcomm, jtask_field_Comm_task, jtask_local); - MSG_task_set_data(task, NULL); + MSG_task_set_data(task, nullptr); } } diff --git a/src/bindings/java/jmsg_file.cpp b/src/bindings/java/jmsg_file.cpp index 5eeca8467d..9f60fc3434 100644 --- a/src/bindings/java/jmsg_file.cpp +++ b/src/bindings/java/jmsg_file.cpp @@ -20,14 +20,14 @@ msg_file_t jfile_get_native(JNIEnv *env, jobject jfile) { JNIEXPORT void JNICALL Java_org_simgrid_msg_File_nativeInit(JNIEnv *env, jclass cls) { jclass class_File = env->FindClass("org/simgrid/msg/File"); jfile_field_bind = jxbt_get_jfield(env , class_File, "bind", "J"); - xbt_assert((jfile_field_bind != NULL), "Can't find \"bind\" field in File class."); + xbt_assert((jfile_field_bind != nullptr), "Can't find \"bind\" field in File class."); } JNIEXPORT void JNICALL Java_org_simgrid_msg_File_open(JNIEnv *env, jobject jfile, jobject jpath) { const char *path = env->GetStringUTFChars((jstring) jpath, 0); msg_file_t file; - file = MSG_file_open(path, NULL); + file = MSG_file_open(path, nullptr); jfile_bind(env, jfile, file); env->ReleaseStringUTFChars((jstring) jpath, path); @@ -52,5 +52,5 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_File_close(JNIEnv *env, jobject jfil msg_file_t file = jfile_get_native(env, jfile); MSG_file_close(file); - jfile_bind(env, jfile, NULL); + jfile_bind(env, jfile, nullptr); } diff --git a/src/bindings/java/jmsg_host.cpp b/src/bindings/java/jmsg_host.cpp index a2cbb893a1..0dc3098e6f 100644 --- a/src/bindings/java/jmsg_host.cpp +++ b/src/bindings/java/jmsg_host.cpp @@ -69,9 +69,9 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jcla jobject jhost; /* global reference to the java host instance returned */ /* get the C string from the java string */ - if (jname == NULL) { + if (jname == nullptr) { jxbt_throw_null(env,bprintf("No host can have a null name")); - return NULL; + return nullptr; } const char *name = env->GetStringUTFChars(jname, 0); /* get the host by name (the hosts are created during the grid resolution) */ @@ -80,7 +80,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jcla if (!host) { /* invalid name */ jxbt_throw_host_not_found(env, name); env->ReleaseStringUTFChars(jname, name); - return NULL; + return nullptr; } env->ReleaseStringUTFChars(jname, name); @@ -90,7 +90,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jcla if (!jhost) { jxbt_throw_jni(env, "java host instantiation failed"); - return NULL; + return nullptr; } /* get a global reference to the newly created host */ @@ -98,7 +98,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jcla if (!jhost) { jxbt_throw_jni(env, "new global ref allocation failed"); - return NULL; + return nullptr; } /* Sets the java host name */ env->SetObjectField(jhost, jhost_field_Host_name, jname); @@ -126,7 +126,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jc if (!jhost) { jxbt_throw_jni(env, "java host instantiation failed"); - return NULL; + return nullptr; } /* get a global reference to the newly created host */ @@ -134,7 +134,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jc if (!jhost) { jxbt_throw_jni(env, "global ref allocation failed"); - return NULL; + return nullptr; } /* Sets the host name */ const char *name = MSG_host_get_name(host); @@ -194,13 +194,13 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getProperty(JNIEnv *env, job if (!host) { jxbt_throw_notbound(env, "host", jhost); - return NULL; + return nullptr; } const char *name = env->GetStringUTFChars((jstring) jname, 0); const char *property = MSG_host_get_property_value(host, name); if (!property) { - return NULL; + return nullptr; } jobject jproperty = env->NewStringUTF(property); @@ -257,14 +257,14 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getMountedStorage(JNIEn int count = xbt_dict_length(dict); jclass cls = env->FindClass("org/simgrid/msg/Storage"); - jtable = env->NewObjectArray((jsize) count, cls, NULL); + jtable = env->NewObjectArray((jsize) count, cls, nullptr); if (!jtable) { jxbt_throw_jni(env, "Storages table allocation failed"); - return NULL; + return nullptr; } - xbt_dict_cursor_t cursor=NULL; + xbt_dict_cursor_t cursor=nullptr; const char* mount_name; const char* storage_name; @@ -291,7 +291,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getAttachedStorage(JNIE xbt_dynar_t dyn = MSG_host_get_attached_storage_list(host); int count = xbt_dynar_length(dyn); jclass cls = jxbt_get_class(env, "java/lang/String"); - jtable = env->NewObjectArray((jsize) count, cls, NULL); + jtable = env->NewObjectArray((jsize) count, cls, nullptr); int index; char *storage_name; jstring jstorage_name; @@ -329,14 +329,14 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclas jclass cls = jxbt_get_class(env, "org/simgrid/msg/Host"); if (!cls) { - return NULL; + return nullptr; } - jtable = env->NewObjectArray((jsize) count, cls, NULL); + jtable = env->NewObjectArray((jsize) count, cls, nullptr); if (!jtable) { jxbt_throw_jni(env, "Hosts table allocation failed"); - return NULL; + return nullptr; } for (index = 0; index < count; index++) { diff --git a/src/bindings/java/jmsg_process.cpp b/src/bindings/java/jmsg_process.cpp index b43ff09f54..4455dd927e 100644 --- a/src/bindings/java/jmsg_process.cpp +++ b/src/bindings/java/jmsg_process.cpp @@ -50,7 +50,7 @@ void jprocess_join(jobject jprocess, JNIEnv * env) { msg_process_t process = jprocess_to_native_process(jprocess,env); simgrid::java::JavaContext* context = (simgrid::java::JavaContext*) MSG_process_get_smx_ctx(process); - xbt_os_thread_join(context->thread,NULL); + xbt_os_thread_join(context->thread,nullptr); } msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env) @@ -115,7 +115,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv * env, jobject jname = jprocess_get_name(jprocess_arg, env); if (!jname) { jxbt_throw_null(env, - xbt_strdup("Internal error: Process name cannot be NULL")); + xbt_strdup("Internal error: Process name cannot be nullptr")); return; } @@ -151,7 +151,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv * env, jobject }, jprocess, host, /*argc, argv, properties*/ - 0, NULL, NULL); + 0, nullptr, nullptr); MSG_process_set_kill_time(process, (double)jkill); /* bind the java process instance to the native process */ jprocess_bind(jprocess, process, env); @@ -165,7 +165,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv * env, jobject env->SetIntField(jprocess, jprocess_field_Process_pid,(jint) MSG_process_get_PID(process)); env->SetIntField(jprocess, jprocess_field_Process_ppid, (jint) MSG_process_get_PPID(process)); /* sets the Host of the process */ - jobject jhost = Java_org_simgrid_msg_Host_getByName(env,NULL, (jstring)jhostname); + jobject jhost = Java_org_simgrid_msg_Host_getByName(env,nullptr, (jstring)jhostname); env->SetObjectField(jprocess, jprocess_field_Process_host, jhost); } @@ -181,14 +181,14 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jcl if (!process) { jxbt_throw_process_not_found(env, bprintf("PID = %d",(int) PID)); - return NULL; + return nullptr; } jobject jprocess = native_to_java_process(process); if (!jprocess) { jxbt_throw_jni(env, "get process failed"); - return NULL; + return nullptr; } return jprocess; @@ -199,13 +199,13 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, if (!process) { jxbt_throw_notbound(env, "process", jprocess); - return NULL; + return nullptr; } const char *name = env->GetStringUTFChars((jstring)jname, 0); const char *property = MSG_process_get_property_value(process, name); if (!property) { - return NULL; + return nullptr; } jobject jproperty = env->NewStringUTF(property); @@ -222,7 +222,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getCurrentProcess(JNIEnv if (!process) { jxbt_throw_jni(env, xbt_strdup("MSG_process_self() failed")); - return NULL; + return nullptr; } jprocess = native_to_java_process(process); @@ -327,7 +327,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep(JNIEnv *env, jclass cl // is a cancelled_error, see bindings/java/smx_context_java.c, function void smx_ctx_java_stop(smx_context_t context) and src/msg/msg_gos.c // function msg_error_t MSG_process_sleep(double nb_sec) - jxbt_throw_host_failure(env,NULL); + jxbt_throw_host_failure(env,nullptr); } } diff --git a/src/bindings/java/jmsg_rngstream.cpp b/src/bindings/java/jmsg_rngstream.cpp index b14662d6c1..11db6a5467 100644 --- a/src/bindings/java/jmsg_rngstream.cpp +++ b/src/bindings/java/jmsg_rngstream.cpp @@ -15,7 +15,7 @@ RngStream jrngstream_to_native(JNIEnv *env, jobject jrngstream) { RngStream rngstream = (RngStream)(intptr_t)env->GetLongField(jrngstream, jrngstream_bind); if (!rngstream) { jxbt_throw_notbound(env, "rngstream", jrngstream); - return NULL; + return nullptr; } return rngstream; } @@ -38,7 +38,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_create(JNIEnv *env, jobjec JNIEXPORT void JNICALL Java_org_simgrid_msg_RngStream_nativeFinalize(JNIEnv *env, jobject jrngstream) { RngStream rngstream = jrngstream_to_native(env, jrngstream); RngStream_DeleteStream(&rngstream); - env->SetLongField(jrngstream, jrngstream_bind, (intptr_t)NULL); + env->SetLongField(jrngstream, jrngstream_bind, (intptr_t)nullptr); } JNIEXPORT jboolean JNICALL diff --git a/src/bindings/java/jmsg_storage.cpp b/src/bindings/java/jmsg_storage.cpp index 8caed69e10..71bb29a775 100644 --- a/src/bindings/java/jmsg_storage.cpp +++ b/src/bindings/java/jmsg_storage.cpp @@ -61,9 +61,9 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j jobject jstorage; /* get the C string from the java string */ - if (jname == NULL) { + if (jname == nullptr) { jxbt_throw_null(env,bprintf("No host can have a null name")); - return NULL; + return nullptr; } const char *name = env->GetStringUTFChars(jname, 0); storage = MSG_storage_get_by_name(name); @@ -71,7 +71,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j if (!storage) { /* invalid name */ jxbt_throw_storage_not_found(env, name); env->ReleaseStringUTFChars(jname, name); - return NULL; + return nullptr; } env->ReleaseStringUTFChars(jname, name); @@ -82,7 +82,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j if (!jstorage) { jxbt_throw_jni(env, "java storage instantiation failed"); - return NULL; + return nullptr; } /* get a global reference to the newly created storage */ @@ -90,7 +90,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j if (!jstorage) { jxbt_throw_jni(env, "new global ref allocation failed"); - return NULL; + return nullptr; } /* Sets the java storage name */ env->SetObjectField(jstorage, jstorage_field_Storage_name, jname); @@ -145,13 +145,13 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getProperty(JNIEnv *env, if (!storage) { jxbt_throw_notbound(env, "storage", jstorage); - return NULL; + return nullptr; } const char *name = env->GetStringUTFChars((jstring) jname, 0); const char *property = MSG_storage_get_property_value(storage, name); if (!property) { - return NULL; + return nullptr; } jobject jproperty = env->NewStringUTF(property); @@ -184,11 +184,11 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getHost(JNIEnv * env,jobj if (!storage) { jxbt_throw_notbound(env, "storage", jstorage); - return NULL; + return nullptr; } const char *host_name = MSG_storage_get_host(storage); if (!host_name) { - return NULL; + return nullptr; } jobject jhost_name = env->NewStringUTF(host_name); @@ -209,14 +209,14 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Storage_all(JNIEnv * env, jc jclass cls = jxbt_get_class(env, "org/simgrid/msg/Storage"); if (!cls) { - return NULL; + return nullptr; } - jtable = env->NewObjectArray((jsize) count, cls, NULL); + jtable = env->NewObjectArray((jsize) count, cls, nullptr); if (!jtable) { jxbt_throw_jni(env, "Storages table allocation failed"); - return NULL; + return nullptr; } for (index = 0; index < count; index++) { diff --git a/src/bindings/java/jmsg_task.cpp b/src/bindings/java/jmsg_task.cpp index b6b45eed90..a7d55458a0 100644 --- a/src/bindings/java/jmsg_task.cpp +++ b/src/bindings/java/jmsg_task.cpp @@ -61,7 +61,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_create(JNIEnv * env, jobject jt jdouble jflopsAmount, jdouble jbytesAmount) { msg_task_t task; /* the native task to create */ - const char *name = NULL; /* the name of the task */ + const char *name = nullptr; /* the name of the task */ if (jflopsAmount < 0) { jxbt_throw_illegal(env, bprintf("Task flopsAmount (%f) cannot be negative", (double) jflopsAmount)); @@ -79,7 +79,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_create(JNIEnv * env, jobject jt } /* create the task */ - task = MSG_task_create(name, (double) jflopsAmount, (double) jbytesAmount, NULL); + task = MSG_task_create(name, (double) jflopsAmount, (double) jbytesAmount, nullptr); if (jname) env->ReleaseStringUTFChars(jname, name); /* sets the task name */ @@ -143,7 +143,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_parallelCreate(JNIEnv * env, jo /* get the C string from the java string */ name = env->GetStringUTFChars(jname, 0); - task = MSG_parallel_task_create(name, host_count, hosts, computeDurations, messageSizes, NULL); + task = MSG_parallel_task_create(name, host_count, hosts, computeDurations, messageSizes, nullptr); env->ReleaseStringUTFChars(jname, name); /* sets the task name */ @@ -204,7 +204,7 @@ JNIEXPORT jstring JNICALL Java_org_simgrid_msg_Task_getName(JNIEnv * env, jobjec if (!task) { jxbt_throw_notbound(env, "task", jtask); - return NULL; + return nullptr; } return env->NewStringUTF(MSG_task_get_name(task)); @@ -217,12 +217,12 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSender(JNIEnv * env, jobj if (!task) { jxbt_throw_notbound(env, "task", jtask); - return NULL; + return nullptr; } process = MSG_task_get_sender(task); - if (process == NULL) { - return NULL; + if (process == nullptr) { + return nullptr; } return (jobject) native_to_java_process(process); } @@ -234,16 +234,16 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_getSource(JNIEnv * env, jobj if (!task) { jxbt_throw_notbound(env, "task", jtask); - return NULL; + return nullptr; } host = MSG_task_get_source(task); - if (host == NULL) { - return NULL; + if (host == nullptr) { + return nullptr; } if (!host->extension(JAVA_HOST_LEVEL)) { jxbt_throw_jni(env, "MSG_task_get_source() failed"); - return NULL; + return nullptr; } return (jobject) host->extension(JAVA_HOST_LEVEL); @@ -359,9 +359,9 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_sendBounded(JNIEnv * env,jobjec JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receive(JNIEnv * env, jclass cls, jstring jalias, jdouble jtimeout, jobject jhost) { - msg_task_t task = NULL; + msg_task_t task = nullptr; - msg_host_t host = NULL; + msg_host_t host = nullptr; jobject jtask_global, jtask_local; if (jhost) { @@ -369,24 +369,24 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receive(JNIEnv * env, jclass if (!host) { jxbt_throw_notbound(env, "host", jhost); - return NULL; + return nullptr; } } const char *alias = env->GetStringUTFChars(jalias, 0); msg_error_t rv = MSG_task_receive_ext(&task, alias, (double) jtimeout, host); if (env->ExceptionOccurred()) - return NULL; + return nullptr; if (rv != MSG_OK) { jmsg_throw_status(env,rv); - return NULL; + return nullptr; } jtask_global = (jobject) MSG_task_get_data(task); /* Convert the global ref into a local ref so that the JVM can free the stuff */ jtask_local = env->NewLocalRef(jtask_global); env->DeleteGlobalRef(jtask_global); - MSG_task_set_data(task, NULL); + MSG_task_set_data(task, nullptr); env->ReleaseStringUTFChars(jalias, alias); @@ -399,19 +399,19 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecv(JNIEnv * env, jclass c jclass comm_class; //pointer to store the task object pointer. msg_task_t *task = xbt_new(msg_task_t,1); - *task = NULL; + *task = nullptr; /* There should be a cache here */ comm_class = env->FindClass("org/simgrid/msg/Comm"); if (!comm_class) { jxbt_throw_native(env,bprintf("fieldID or methodID or class not found.")); - return NULL; + return nullptr; } jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor); if (!jcomm) { jxbt_throw_native(env,bprintf("Can't create a Comm object.")); - return NULL; + return nullptr; } mailbox = env->GetStringUTFChars(jmailbox, 0); @@ -432,9 +432,9 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receiveBounded(JNIEnv * env, { msg_error_t rv; msg_task_t *task = xbt_new(msg_task_t,1); - *task = NULL; + *task = nullptr; - msg_host_t host = NULL; + msg_host_t host = nullptr; jobject jtask_global, jtask_local; const char *alias; @@ -443,24 +443,24 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receiveBounded(JNIEnv * env, if (!host) { jxbt_throw_notbound(env, "host", jhost); - return NULL; + return nullptr; } } alias = env->GetStringUTFChars(jalias, 0); rv = MSG_task_receive_ext_bounded(task, alias, (double) jtimeout, host, (double) rate); if (env->ExceptionOccurred()) - return NULL; + return nullptr; if (rv != MSG_OK) { jmsg_throw_status(env,rv); - return NULL; + return nullptr; } jtask_global = (jobject) MSG_task_get_data(*task); /* Convert the global ref into a local ref so that the JVM can free the stuff */ jtask_local = env->NewLocalRef(jtask_global); env->DeleteGlobalRef(jtask_global); - MSG_task_set_data(*task, NULL); + MSG_task_set_data(*task, nullptr); env->ReleaseStringUTFChars(jalias, alias); @@ -477,19 +477,19 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecvBounded(JNIEnv * env, j jclass comm_class; //pointer to store the task object pointer. msg_task_t *task = xbt_new(msg_task_t,1); - *task = NULL; + *task = nullptr; /* There should be a cac hee */ comm_class = env->FindClass("org/simgrid/msg/Comm"); if (!comm_class) { jxbt_throw_native(env,bprintf("fieldID or methodID or class not found.")); - return NULL; + return nullptr; } jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor); if (!jcomm) { jxbt_throw_native(env,bprintf("Can't create a Comm object.")); - return NULL; + return nullptr; } mailbox = env->GetStringUTFChars(jmailbox, 0); @@ -515,7 +515,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isend(JNIEnv *env, jobject j comm_class = env->FindClass("org/simgrid/msg/Comm"); - if (!comm_class) return NULL; + if (!comm_class) return nullptr; jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor); mailbox = env->GetStringUTFChars(jmailbox, 0); @@ -526,14 +526,14 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isend(JNIEnv *env, jobject j env->ReleaseStringUTFChars(jmailbox, mailbox); env->DeleteLocalRef(jcomm); jxbt_throw_notbound(env, "task", jtask); - return NULL; + return nullptr; } MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask)); comm = MSG_task_isend(task,mailbox); env->SetLongField(jcomm, jtask_field_Comm_bind, (jlong) (uintptr_t)(comm)); - env->SetLongField(jcomm, jtask_field_Comm_taskBind, (jlong) (uintptr_t)(NULL)); + env->SetLongField(jcomm, jtask_field_Comm_taskBind, (jlong) (uintptr_t)(nullptr)); env->SetBooleanField(jcomm, jtask_field_Comm_receiving, JNI_FALSE); env->ReleaseStringUTFChars(jmailbox, mailbox); @@ -552,7 +552,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isendBounded(JNIEnv *env, jo comm_class = env->FindClass("org/simgrid/msg/Comm"); - if (!comm_class) return NULL; + if (!comm_class) return nullptr; jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor); mailbox = env->GetStringUTFChars(jmailbox, 0); @@ -563,14 +563,14 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isendBounded(JNIEnv *env, jo env->ReleaseStringUTFChars(jmailbox, mailbox); env->DeleteLocalRef(jcomm); jxbt_throw_notbound(env, "task", jtask); - return NULL; + return nullptr; } MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask)); comm = MSG_task_isend_bounded(task,mailbox,maxrate); env->SetLongField(jcomm, jtask_field_Comm_bind, (jlong) (uintptr_t)(comm)); - env->SetLongField(jcomm, jtask_field_Comm_taskBind, (jlong) (uintptr_t)(NULL)); + env->SetLongField(jcomm, jtask_field_Comm_taskBind, (jlong) (uintptr_t)(nullptr)); env->SetBooleanField(jcomm, jtask_field_Comm_receiving, JNI_FALSE); env->ReleaseStringUTFChars(jmailbox, mailbox); @@ -597,7 +597,7 @@ static void msg_task_cancel_on_failed_dsend(void*t) { /* Destroy the global ref so that the JVM can free the stuff */ env->DeleteGlobalRef(jtask_global); - MSG_task_set_data(task, NULL); + MSG_task_set_data(task, nullptr); MSG_task_destroy(task); } diff --git a/src/bindings/java/jmsg_vm.cpp b/src/bindings/java/jmsg_vm.cpp index 608d9f8248..7ab77aa72a 100644 --- a/src/bindings/java/jmsg_vm.cpp +++ b/src/bindings/java/jmsg_vm.cpp @@ -100,7 +100,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv *env, jobject jvm, // disk_path = (*env)->GetStringUTFChars(env, jdiskpath, 0); // disk_path = xbt_strdup(disk_path); - msg_vm_t vm = MSG_vm_create(host, name, (int) jncore, (int) jramsize, (int) jnetcap, NULL, (int) jdisksize, + msg_vm_t vm = MSG_vm_create(host, name, (int) jncore, (int) jramsize, (int) jnetcap, nullptr, (int) jdisksize, (int) jmig_netspeed, (int) jdp_intensity); jvm_bind(env,jvm,vm); diff --git a/src/bindings/java/jxbt_utilities.cpp b/src/bindings/java/jxbt_utilities.cpp index 885d9d5f9e..27b4dddfae 100644 --- a/src/bindings/java/jxbt_utilities.cpp +++ b/src/bindings/java/jxbt_utilities.cpp @@ -20,7 +20,7 @@ jclass jxbt_get_class(JNIEnv * env, const char *name) char *m = bprintf("Class %s not found", name); jxbt_throw_jni(env, m); free(m); - return NULL; + return nullptr; } return cls; @@ -37,7 +37,7 @@ jmethodID jxbt_get_jmethod(JNIEnv * env, jclass cls, const char *name, const cha if (!id) { jmethodID tostr_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;"); - jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, NULL); + jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, nullptr); const char *classname = env->GetStringUTFChars(jclassname, 0); char *m = bprintf("Cannot find method %s(%s) in %s", name, signature, classname); @@ -63,7 +63,7 @@ jmethodID jxbt_get_static_jmethod(JNIEnv * env, jclass cls, const char *name, co if (!id) { jmethodID tostr_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;"); - jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, NULL); + jstring jclassname = (jstring) env->CallObjectMethod(cls, tostr_id, nullptr); const char *classname = env->GetStringUTFChars(jclassname, 0); char *m = bprintf("Cannot find static method %s(%s) in %s", name, signature, classname); @@ -134,7 +134,7 @@ jfieldID jxbt_get_jfield(JNIEnv * env, jclass cls, const char *name, const char if (!id) { jmethodID getname_id = env->GetMethodID(cls, "getName", "()Ljava/lang/String;"); - jstring jclassname = (jstring) env->CallObjectMethod(cls, getname_id, NULL); + jstring jclassname = (jstring) env->CallObjectMethod(cls, getname_id, nullptr); const char *classname = env->GetStringUTFChars(jclassname, 0); char *m = bprintf("Cannot find field %s %s in %s", signature, name, classname); diff --git a/src/bindings/lua/lua_debug.cpp b/src/bindings/lua/lua_debug.cpp index 171b847506..8b72e6ac52 100644 --- a/src/bindings/lua/lua_debug.cpp +++ b/src/bindings/lua/lua_debug.cpp @@ -8,7 +8,7 @@ /* * This file contains functions that aid users to debug their lua scripts; for instance, * tables can be easily output and values are represented in a human-readable way. (For instance, - * a NULL value becomes the string "nil"). + * a nullptr value becomes the string "nil"). * */ /* SimGrid Lua debug functions */ @@ -190,7 +190,7 @@ void* sglua_checkudata_debug(lua_State* L, int ud, const char* tname) int has_mt = lua_getmetatable(L, ud); XBT_DEBUG("Checking the userdata: has metatable ? %d", has_mt); - const void* actual_mt = NULL; + const void* actual_mt = nullptr; if (has_mt) { actual_mt = lua_topointer(L, -1); lua_pop(L, 1); @@ -198,8 +198,8 @@ 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 == NULL || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2)) - XBT_ERROR("Error: Userdata is NULL, couldn't find metatable or top of stack does not equal element below it."); + if (p == nullptr || !lua_getmetatable(L, ud) || !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 797dadef36..74d4f8208d 100644 --- a/src/bindings/lua/lua_host.cpp +++ b/src/bindings/lua/lua_host.cpp @@ -32,8 +32,8 @@ sg_host_t sglua_check_host(lua_State * L, int index) lua_getfield(L, index, HOST_FIELDNAME); sg_host_t *pi = (sg_host_t *) luaL_checkudata(L, lua_gettop(L), HOST_MODULE_NAME); lua_pop(L, 1); - if (pi == NULL) - XBT_ERROR("luaL_checkudata() returned NULL"); + if (pi == nullptr) + XBT_ERROR("luaL_checkudata() returned nullptr"); sg_host_t ht = *pi; if (!ht) luaL_error(L, "null Host"); @@ -160,7 +160,7 @@ static const luaL_Reg host_functions[] = { {"destroy", l_host_destroy}, // Bypass XML Methods {"set_property", console_host_set_property}, - {NULL, NULL} + {nullptr, nullptr} }; /** diff --git a/src/bindings/lua/lua_platf.cpp b/src/bindings/lua/lua_platf.cpp index bc870a619f..9ea766aeac 100644 --- a/src/bindings/lua/lua_platf.cpp +++ b/src/bindings/lua/lua_platf.cpp @@ -41,7 +41,7 @@ static const luaL_Reg platf_functions[] = { {"router_new", console_add_router}, {"route_new", console_add_route}, {"ASroute_new", console_add_ASroute}, - {NULL, NULL} + {nullptr, nullptr} }; int console_open(lua_State *L) { @@ -65,7 +65,7 @@ int console_add_backbone(lua_State *L) { memset(&link,0,sizeof(link)); int type; - link.properties = NULL; + link.properties = nullptr; lua_ensure(lua_istable(L, -1),"Bad Arguments to create backbone in Lua. Should be a table with named arguments."); @@ -162,7 +162,7 @@ int console_add_host(lua_State *L) { type = lua_gettable(L, -2); lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER, "Attribute 'speed' must be specified for host and must either be a string (in the correct format; check documentation) or a number."); - host.speed_per_pstate = xbt_dynar_new(sizeof(double), NULL); + host.speed_per_pstate = xbt_dynar_new(sizeof(double), nullptr); if (type == LUA_TNUMBER) xbt_dynar_push_as(host.speed_per_pstate, double, lua_tointeger(L, -1)); else // LUA_TSTRING @@ -376,8 +376,8 @@ int console_add_route(lua_State *L) { } lua_pop(L,1); - route.gw_src = NULL; - route.gw_dst = NULL; + route.gw_src = nullptr; + route.gw_dst = nullptr; sg_platf_new_route(&route); @@ -528,7 +528,7 @@ int console_host_set_property(lua_State *L) { sg_host_t host = sg_host_by_name(name); lua_ensure(host, "no host '%s' found",name); xbt_dict_t props = sg_host_get_properties(host); - xbt_dict_set(props,prop_id,xbt_strdup(prop_value),NULL); + xbt_dict_set(props,prop_id,xbt_strdup(prop_value),nullptr); return 0; } diff --git a/src/bindings/lua/simgrid_lua.cpp b/src/bindings/lua/simgrid_lua.cpp index 61fcd2f84e..91b854fd65 100644 --- a/src/bindings/lua/simgrid_lua.cpp +++ b/src/bindings/lua/simgrid_lua.cpp @@ -104,7 +104,7 @@ static const luaL_Reg simgrid_functions[] = { {"info", info}, {"critical", critical}, {"error", error}, - {NULL, NULL} + {nullptr, nullptr} }; /* ********************************************************************************* */