X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7db4d75e5804aac4f85c4b83c650552b25091c3e..3907e83884bae6278656e9cd2cb7ef92a8f707fb:/examples/smpi/ampi_test/ampi_test.cpp diff --git a/examples/smpi/ampi_test/ampi_test.cpp b/examples/smpi/ampi_test/ampi_test.cpp index bc02cadd84..53308b1b67 100644 --- a/examples/smpi/ampi_test/ampi_test.cpp +++ b/examples/smpi/ampi_test/ampi_test.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2009-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -12,13 +12,16 @@ int main(int argc, char* argv[]) MPI_Init(&argc, &argv); // useless alocations for testing and coverage void* pointer = malloc(100 * sizeof(int)); - pointer = realloc(pointer, 50 * sizeof(int)); - pointer = realloc(pointer, 200 * sizeof(int)); + void* ptmp; + if ((ptmp = realloc(pointer, 50 * sizeof(int))) != nullptr) + pointer = ptmp; + if ((ptmp = realloc(pointer, 200 * sizeof(int))) != nullptr) + pointer = ptmp; free(pointer); pointer = calloc(100, sizeof(int)); int rank; - int err = MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* Get id of this process */ - if (err != MPI_SUCCESS) { + /* Get id of this process */ + if (int err = MPI_Comm_rank(MPI_COMM_WORLD, &rank); err != MPI_SUCCESS) { fprintf(stderr, "MPI_Comm_rank failed: %d", err); MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); exit(EXIT_FAILURE);