From ad5ef1b2a27d2ed3f753e6d67a16a07178889fd1 Mon Sep 17 00:00:00 2001
From: "raphael.bach" <raphael.bach@etu.hesge.ch>
Date: Tue, 14 Jun 2022 23:33:33 +0200
Subject: [PATCH] Make code const correct

---
 include/fmpi_core.h         | 2 +-
 include/fmpi_task.h         | 4 ++--
 include/internal/fmpi_mpi.h | 2 +-
 src/fmpi_core.c             | 4 ++--
 src/fmpi_ctx.c              | 2 +-
 src/fmpi_futhark.c          | 2 +-
 src/fmpi_mpi.c              | 2 +-
 src/fmpi_stencil.c          | 4 ++--
 src/fmpi_task.c             | 4 ++--
 9 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/fmpi_core.h b/include/fmpi_core.h
index 81fc2f6..25ea8a0 100644
--- a/include/fmpi_core.h
+++ b/include/fmpi_core.h
@@ -77,7 +77,7 @@ struct fmpi_ctx * fmpi_init(int * argc, char ** argv[]);
  *  }
  * }
  */
-int fmpi_exit(struct fmpi_ctx ** const ctx);
+int fmpi_exit(struct fmpi_ctx ** ctx);
 /*------------------------------------------------------------------------------
     fmpi_abort()
 ------------------------------------------------------------------------------*/
diff --git a/include/fmpi_task.h b/include/fmpi_task.h
index 98ae439..39d9f88 100644
--- a/include/fmpi_task.h
+++ b/include/fmpi_task.h
@@ -80,7 +80,7 @@ typedef struct fmpi_task_args {
  *  TODO
  * }
  */
-typedef void (*fmpi_task_func)(
+typedef void (* fmpi_task_func)(
     const struct fmpi_ctx * ctx, const struct fmpi_task_args * args
 );
 /*------------------------------------------------------------------------------
@@ -120,7 +120,7 @@ typedef struct fmpi_task {
  * }
  */
 struct fmpi_task fmpi_task_register(
-    struct fmpi_ctx * ctx, const fmpi_task_func func,
+    struct fmpi_ctx * ctx, fmpi_task_func func,
     struct fmpi_stencil stencil, const struct fmpi_task_args * args
 );
 /*------------------------------------------------------------------------------
diff --git a/include/internal/fmpi_mpi.h b/include/internal/fmpi_mpi.h
index adbd6b0..7cf6395 100644
--- a/include/internal/fmpi_mpi.h
+++ b/include/internal/fmpi_mpi.h
@@ -116,7 +116,7 @@ int fmpi_mpi_exit(struct fmpi_mpi_ctx ** ctx);
  *  TODO
  * }
  */
-_Bool fmpi_mpi_is_root(const struct fmpi_mpi_ctx * const ctx);
+_Bool fmpi_mpi_is_root(const struct fmpi_mpi_ctx * ctx);
 /*------------------------------------------------------------------------------
     fmpi_mpi_check_error()
 ------------------------------------------------------------------------------*/
diff --git a/src/fmpi_core.c b/src/fmpi_core.c
index 3988c6f..37cbe3e 100644
--- a/src/fmpi_core.c
+++ b/src/fmpi_core.c
@@ -37,7 +37,7 @@
 /*------------------------------------------------------------------------------
     fmpi_init()
 ------------------------------------------------------------------------------*/
-struct fmpi_ctx * fmpi_init(int * const argc, char *** const argv)
+struct fmpi_ctx * fmpi_init(int * const argc, char ** argv[])
 {
     struct fmpi_ctx * ctx = fmpi_ctx_create(argc, argv);
     if(ctx == NULL) {
@@ -66,7 +66,7 @@ _Noreturn void fmpi_abort(const struct fmpi_ctx * const ctx)
 /*------------------------------------------------------------------------------
     fmpi_is_root()
 ------------------------------------------------------------------------------*/
-_Bool fmpi_is_root(const struct fmpi_ctx * ctx)
+_Bool fmpi_is_root(const struct fmpi_ctx * const ctx)
 {
     assert(ctx != NULL);
     return fmpi_mpi_is_root(ctx->mpi);
diff --git a/src/fmpi_ctx.c b/src/fmpi_ctx.c
index c8afbfc..e265efe 100644
--- a/src/fmpi_ctx.c
+++ b/src/fmpi_ctx.c
@@ -52,7 +52,7 @@ static void fmpi_ctx_print_error(
 /*------------------------------------------------------------------------------
     fmpi_ctx_create()
 ------------------------------------------------------------------------------*/
-struct fmpi_ctx * fmpi_ctx_create(int * argc, char ** argv[])
+struct fmpi_ctx * fmpi_ctx_create(int * const argc, char ** argv[])
 {
     struct fmpi_ctx * ctx = malloc(sizeof(*ctx));
     struct fmpi_error_handler err_handler = {
diff --git a/src/fmpi_futhark.c b/src/fmpi_futhark.c
index 173119c..2bd0042 100644
--- a/src/fmpi_futhark.c
+++ b/src/fmpi_futhark.c
@@ -140,7 +140,7 @@ _Bool fmpi_futhark_check_error(
     fmpi_futhark_new_data()
 ------------------------------------------------------------------------------*/
 void * fmpi_futhark_new_data(
-    const struct fmpi_futhark_ctx * ctx, const void * const data,
+    const struct fmpi_futhark_ctx * const ctx, const void * const data,
     const enum fmpi_type type, const size_t dim_cnt,
     const size_t x, const size_t y, const size_t z
 ){
diff --git a/src/fmpi_mpi.c b/src/fmpi_mpi.c
index 1609ec4..5df12e6 100644
--- a/src/fmpi_mpi.c
+++ b/src/fmpi_mpi.c
@@ -52,7 +52,7 @@ do { \
     fmpi_mpi_init()
 ------------------------------------------------------------------------------*/
 struct fmpi_mpi_ctx * fmpi_mpi_init(
-    int * const argc, char *** const argv,
+    int * const argc, char **  argv[],
     const struct fmpi_error_handler err_handler
 ){
     struct fmpi_mpi_ctx * ctx = malloc(sizeof(*ctx));
diff --git a/src/fmpi_stencil.c b/src/fmpi_stencil.c
index 825bc50..9197e22 100644
--- a/src/fmpi_stencil.c
+++ b/src/fmpi_stencil.c
@@ -42,7 +42,7 @@ struct fmpi_stencil fmpi_no_stencil(void)
 /*------------------------------------------------------------------------------
     fmpi_stencil_1d()
 ------------------------------------------------------------------------------*/
-struct fmpi_stencil fmpi_stencil_1d(size_t length)
+struct fmpi_stencil fmpi_stencil_1d(const size_t length)
 {
     return (struct fmpi_stencil){
         .type = FMPI_STENCIL_SQUARE,
@@ -53,7 +53,7 @@ struct fmpi_stencil fmpi_stencil_1d(size_t length)
 /*------------------------------------------------------------------------------
     fmpi_stencil_2d()
 ------------------------------------------------------------------------------*/
-struct fmpi_stencil fmpi_stencil_2d(size_t length)
+struct fmpi_stencil fmpi_stencil_2d(const size_t length)
 {
     return (struct fmpi_stencil){
         .type = FMPI_STENCIL_SQUARE,
diff --git a/src/fmpi_task.c b/src/fmpi_task.c
index b4efc4e..f3554e8 100644
--- a/src/fmpi_task.c
+++ b/src/fmpi_task.c
@@ -40,8 +40,8 @@
     fmpi_task_register()
 ------------------------------------------------------------------------------*/
 struct fmpi_task fmpi_task_register(
-    struct fmpi_ctx * ctx, const fmpi_task_func func,
-    const struct fmpi_stencil stencil, const struct fmpi_task_args * args
+    struct fmpi_ctx * const ctx, const fmpi_task_func func,
+    const struct fmpi_stencil stencil, const struct fmpi_task_args * const args
 ){
     assert(ctx != NULL);
     assert(ctx->task_cnt < FMPI_TASK_MAX);
-- 
GitLab