Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[MBI] Make array initialization explicit.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 30 Mar 2022 12:39:15 +0000 (14:39 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 30 Mar 2022 19:10:51 +0000 (21:10 +0200)
PVS-studio: V1009. Check the array initialization. Only the first element is initialized explicitly.

teshsuite/smpi/MBI/RMAInvalidArgGenerator.py
teshsuite/smpi/MBI/RMAWinBufferGenerator.py
teshsuite/smpi/MBI/generator_utils.py

index 6a5e40a..d562305 100755 (executable)
@@ -127,6 +127,7 @@ for e in gen.epoch:
         replace['longdesc'] = 'Use of an invalid buffer in MPI_Win_create.'
         replace['outcome'] = 'ERROR: InvalidBuffer'
         patterns['malloc'] = "NULL; /* MBIERROR2 */"
+        replace['init'] = ""
         patterns['operation'] = ""
         replace['change_arg'] = ""
         replace['errormsg'] = 'Invalid buffer in Win_create at @{filename}@:@{line:MBIERROR2}@'
index 8987f28..0830075 100755 (executable)
@@ -65,7 +65,8 @@ int main(int argc, char *argv[]) {
   MPI_Win_fence(0, win);
 
   if (rank == 0) {
-    int localbuf[N] = {12345};
+    int localbuf[N] = {0};
+    localbuf[0] = 12345;
     MPI_Put(&localbuf, N, MPI_INT, 1, 0, N, MPI_INT, win);
   }
 
index e249a3d..78f5b5e 100644 (file)
@@ -393,10 +393,10 @@ finEpoch['MPI_Win_lock'] = lambda n: 'MPI_Win_unlock(target, win);'
 epoch['MPI_Win_lock_all'] = lambda n: 'MPI_Win_lock_all(0,win);'
 finEpoch['MPI_Win_lock_all'] = lambda n: 'MPI_Win_unlock_all(win);'
 
-init['MPI_Put'] = lambda n: f'int localbuf{n}[N] = {{12345}};'
+init['MPI_Put'] = lambda n: f'int localbuf{n}[N] = {{0}};\n  localbuf{n}[0] = 12345;'
 operation['MPI_Put'] = lambda n: f'MPI_Put(&localbuf{n}, N, MPI_INT, target, 0, N, type, win);'
 
-init['MPI_Get'] = lambda n: f'int localbuf{n}[N] = {{54321}};'
+init['MPI_Get'] = lambda n: f'int localbuf{n}[N] = {{0}};\n  localbuf{n}[0] = 54321;'
 operation['MPI_Get'] = lambda n: f'MPI_Get(&localbuf{n}, N, MPI_INT, target, 0, N, type, win);'
 
 init['store'] = lambda n: f'int localbuf{n}[N] = {{0}};'