Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Constify pointer and reference local variables in src/bindings/.
[simgrid.git] / src / bindings / java / jmsg_host.cpp
index 550c172..b895ed0 100644 (file)
@@ -53,8 +53,8 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_nativeInit(JNIEnv *env, jclass
              "Native initialization of msg/Host failed. Please report that bug");
 }
 
-JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls, jstring jname) {
-
+JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv* env, jclass cls, jstring jname)
+{
   /* get the C string from the java string */
   if (jname == nullptr) {
     jxbt_throw_null(env, "No host can have a null name");
@@ -108,7 +108,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jc
   if (not host->extension(JAVA_HOST_LEVEL)) {
     /* the native host not yet associated with the java host instance */
 
-    /* instanciate a new java host instance */
+    /* instantiate a new java host instance */
     jhost = jhost_new_instance(env);
 
     if (not jhost) {
@@ -207,7 +207,7 @@ Java_org_simgrid_msg_Host_setProperty(JNIEnv *env, jobject jhost, jobject jname,
   }
   const char *name = env->GetStringUTFChars((jstring) jname, 0);
   const char *value_java = env->GetStringUTFChars((jstring) jvalue, 0);
-  char *value = xbt_strdup(value_java);
+  const char* value      = xbt_strdup(value_java);
 
   MSG_host_set_property_value(host, name, value);
 
@@ -297,7 +297,6 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getStorageContent(JNIEn
 
 JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclass cls_arg)
 {
-
   xbt_dynar_t table =  MSG_hosts_as_dynar();
   int count = xbt_dynar_length(table);
 
@@ -313,7 +312,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclas
   }
 
   for (int index = 0; index < count; index++) {
-    msg_host_t host = xbt_dynar_get_as(table, index, msg_host_t);
+    auto const* host = xbt_dynar_get_as(table, index, msg_host_t);
     jobject jhost   = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
 
     if (not jhost) {