From 053ad25a2831282c8e598640006b6c9a0c8abcd8 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Fri, 28 Jul 2017 11:16:41 +0200
Subject: [PATCH] Keep working on some cleanup

---
 CMakeLists.txt                            | 23 ++++----
 cmake_modules/GenHQRPkgConfig.cmake       | 66 +++++++++++------------
 include/libhqr.h                          | 55 +++++++++++++------
 include/libhqr_common.h                   | 29 ----------
 include/libhqr_draw.h                     | 46 ----------------
 include/libhqr_queue.h                    | 14 ++---
 lib/pkgconfig/{libhqr.pc.in => hqr.pc.in} |  7 +--
 src/check.c                               | 24 ++++++---
 src/gensvg.c                              | 20 +++----
 src/hqr.c                                 |  5 +-
 src/queue.c                               | 19 ++++---
 src/svd.c                                 |  4 +-
 testings/draw_hqr.c                       |  1 -
 testings/draw_systolic.c                  |  1 -
 14 files changed, 133 insertions(+), 181 deletions(-)
 delete mode 100644 include/libhqr_common.h
 delete mode 100644 include/libhqr_draw.h
 rename lib/pkgconfig/{libhqr.pc.in => hqr.pc.in} (71%)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 020837b..f77fe96 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,7 +14,7 @@ project (HQR C)
 # Check if compiled independtly or within another project
 if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
   set( BUILD_SUBPROJECT OFF )
-  set( INSTALL_HDR_DIR include/hqr )
+  set( INSTALL_HDR_DIR include )
 else()
   set( BUILD_SUBPROJECT ON )
   set( INSTALL_HDR_DIR include/chameleon )
@@ -40,31 +40,33 @@ if ( NOT BUILD_SUBPROJECT )
 endif()
 
 set(hdrs
-  include/common.h
-  include/libdraw.h
   include/libhqr.h
-  include/queue.h
+  include/libhqr_internal.h
+  include/libhqr_queue.h
 )
 set(srcs
+  # Low level tree functions
   src/low_flat.c
   src/low_binary.c
   src/low_fibonacci.c
   src/low_greedy.c
   src/low_greedy1p.c
   src/low_adaptiv.c
+  # High level tree functions
   src/high_flat.c
   src/high_binary.c
   src/high_fibonacci.c
   src/high_greedy.c
+  # Direct access tree functions
   src/systolic.c
   src/svd.c
-  src/mtxtree.c
   src/hqr.c
+  src/mtxtree.c
+  # Others
   src/check.c
   src/gendot.c
   src/gensvg.c
   src/queue.c
-  src/treedraw.c
 )
 
 include_directories(include)
@@ -75,13 +77,14 @@ add_subdirectory(testings)
 
 install(FILES
   include/libhqr.h
-  include/libhqr_common.h
-  #  include/libhqr_dbg.h
   DESTINATION ${INSTALL_HDR_DIR} )
 
-install(TARGETS hqr DESTINATION lib)
+install(TARGETS hqr
+  RUNTIME DESTINATION bin
+  ARCHIVE DESTINATION lib
+  LIBRARY DESTINATION lib)
 
-#generate_hqr_pkgconfig_file()
+generate_hqr_pkgconfig_file()
 
 #-- Add a custom target to generate tags
 add_custom_target (tags
diff --git a/cmake_modules/GenHQRPkgConfig.cmake b/cmake_modules/GenHQRPkgConfig.cmake
index b20623e..efe6150 100644
--- a/cmake_modules/GenHQRPkgConfig.cmake
+++ b/cmake_modules/GenHQRPkgConfig.cmake
@@ -33,26 +33,26 @@
 #                                used in CLEAN_LIB_LIST
 #
 ###
-macro(CONVERT_LIBSTYLE_TO_PKGCONFIG _liblist)
-    set(${_liblist}_CPY "${${_liblist}}")
-    set(${_liblist} "")
-    foreach(_dep ${${_liblist}_CPY})
-        if (${_dep} MATCHES "^/")
-            get_filename_component(dep_libname ${_dep} NAME)
-            get_filename_component(dep_libdir  ${_dep} DIRECTORY)
-            string(REPLACE "lib"    "" dep_libname "${dep_libname}")
-            string(REPLACE ".so"    "" dep_libname "${dep_libname}")
-            string(REPLACE ".a"     "" dep_libname "${dep_libname}")
-            string(REPLACE ".dylib" "" dep_libname "${dep_libname}")
-            string(REPLACE ".dll"   "" dep_libname "${dep_libname}")
-            list(APPEND ${_liblist} -L${dep_libdir} -l${dep_libname})
-        elseif(NOT ${_dep} MATCHES "^-")
-            list(APPEND ${_liblist} "-l${_dep}")
-        else()
-            list(APPEND ${_liblist} ${_dep})
-        endif()
-    endforeach()
-endmacro(CONVERT_LIBSTYLE_TO_PKGCONFIG)
+# macro(CONVERT_LIBSTYLE_TO_PKGCONFIG _liblist)
+#     set(${_liblist}_CPY "${${_liblist}}")
+#     set(${_liblist} "")
+#     foreach(_dep ${${_liblist}_CPY})
+#         if (${_dep} MATCHES "^/")
+#             get_filename_component(dep_libname ${_dep} NAME)
+#             get_filename_component(dep_libdir  ${_dep} DIRECTORY)
+#             string(REPLACE "lib"    "" dep_libname "${dep_libname}")
+#             string(REPLACE ".so"    "" dep_libname "${dep_libname}")
+#             string(REPLACE ".a"     "" dep_libname "${dep_libname}")
+#             string(REPLACE ".dylib" "" dep_libname "${dep_libname}")
+#             string(REPLACE ".dll"   "" dep_libname "${dep_libname}")
+#             list(APPEND ${_liblist} -L${dep_libdir} -l${dep_libname})
+#         elseif(NOT ${_dep} MATCHES "^-")
+#             list(APPEND ${_liblist} "-l${_dep}")
+#         else()
+#             list(APPEND ${_liblist} ${_dep})
+#         endif()
+#     endforeach()
+# endmacro(CONVERT_LIBSTYLE_TO_PKGCONFIG)
 
 ###
 #
@@ -60,18 +60,18 @@ endmacro(CONVERT_LIBSTYLE_TO_PKGCONFIG)
 #                 used in GENERATE_PKGCONFIG_FILE
 #
 ###
-macro(CLEAN_LIB_LIST _package)
-    list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_LIBS)
-    list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_LIBS_PRIVATE)
-    list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_REQUIRED)
-    list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_REQUIRED_PRIVATE)
-    convert_libstyle_to_pkgconfig(${_package}_PKGCONFIG_LIBS)
-    convert_libstyle_to_pkgconfig(${_package}_PKGCONFIG_LIBS_PRIVATE)
-    string(REPLACE ";" " " ${_package}_PKGCONFIG_LIBS "${${_package}_PKGCONFIG_LIBS}")
-    string(REPLACE ";" " " ${_package}_PKGCONFIG_LIBS_PRIVATE "${${_package}_PKGCONFIG_LIBS_PRIVATE}")
-    string(REPLACE ";" " " ${_package}_PKGCONFIG_REQUIRED "${${_package}_PKGCONFIG_REQUIRED}")
-    string(REPLACE ";" " " ${_package}_PKGCONFIG_REQUIRED_PRIVATE "${${_package}_PKGCONFIG_REQUIRED_PRIVATE}")
-endmacro(CLEAN_LIB_LIST)
+#macro(CLEAN_LIB_LIST _package)
+#    list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_LIBS)
+#    list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_LIBS_PRIVATE)
+#    list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_REQUIRED)
+#    list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_REQUIRED_PRIVATE)
+#    convert_libstyle_to_pkgconfig(${_package}_PKGCONFIG_LIBS)
+#    convert_libstyle_to_pkgconfig(${_package}_PKGCONFIG_LIBS_PRIVATE)
+#    string(REPLACE ";" " " ${_package}_PKGCONFIG_LIBS "${${_package}_PKGCONFIG_LIBS}")
+#    string(REPLACE ";" " " ${_package}_PKGCONFIG_LIBS_PRIVATE "${${_package}_PKGCONFIG_LIBS_PRIVATE}")
+#    string(REPLACE ";" " " ${_package}_PKGCONFIG_REQUIRED "${${_package}_PKGCONFIG_REQUIRED}")
+#    string(REPLACE ";" " " ${_package}_PKGCONFIG_REQUIRED_PRIVATE "${${_package}_PKGCONFIG_REQUIRED_PRIVATE}")
+#endmacro(CLEAN_LIB_LIST)
 
 ###
 #
@@ -85,7 +85,7 @@ macro(GENERATE_HQR_PKGCONFIG_FILE)
   set(HQR_PKGCONFIG_REQUIRED "")
   set(HQR_PKGCONFIG_REQUIRED_PRIVATE "")
 
-  clean_lib_list(LIBHQR)
+  #clean_lib_list(LIBHQR)
 
   set(_output_libhqr_file "${CMAKE_BINARY_DIR}/hqr.pc")
   configure_file(
diff --git a/include/libhqr.h b/include/libhqr.h
index e56fb0e..16122b2 100644
--- a/include/libhqr.h
+++ b/include/libhqr.h
@@ -51,8 +51,8 @@ BEGIN_C_DECLS
  *     matrices.
  *
  * @remark LIBHQR_KILLED_BY_TS needs to be 0 for all variant of QR
- * factorizations in order to distinguish TT kernels from TS kernels in
- * compuations
+ * factorizations in order to easily distinguish TT kernels from TS kernels in
+ * computations.
  *
  */
 typedef enum libhqr_type_ {
@@ -101,12 +101,16 @@ typedef struct libhqr_matrix_s {
     int p;             /**< The number of nodes per column in the data distribution */
 } libhqr_matrix_t;
 
-struct libhqr_tree_s;
-typedef struct libhqr_tree_s libhqr_tree_t;
-
 /**
  * @brief Hierarchical tree structure for QR/LQ factorization like kernels.
+ *
+ * This structure holds the functions that allows one to traverse the tree, or
+ * to know form each node which ones are its neigbours in the reduction trees.
+ *
  */
+struct libhqr_tree_s;
+typedef struct libhqr_tree_s libhqr_tree_t;
+
 struct libhqr_tree_s {
     /**
      * @brief Return the number of geqrt/gelqt kernels in the column/row k
@@ -192,6 +196,10 @@ struct libhqr_tree_s {
                      tree: hqr, systolic, svd, ...)                                  */
 };
 
+/**
+ * @name Initialization/Finalization functions
+ * @{
+ */
 int  libhqr_init_sys( libhqr_tree_t *qrtree,
                       libhqr_facto_e trans, libhqr_matrix_t *A,
                       int p, int q );
@@ -206,27 +214,40 @@ int  libhqr_init_hqr( libhqr_tree_t *qrtree,
                       int a, int p, int domino, int tsrr );
 void libhqr_finalize( libhqr_tree_t *qrtree );
 
+/**
+ * @}
+ * @name Function to walk the tree in correct order for STF programing model
+ * @{
+ */
 void libhqr_walk_stepk( const libhqr_tree_t *qrtree, int k, int *tiles );
 
-/*
- * Function for drawing the tree
+/**
+ * @}
+ * @name Drawing functions
+ * @{
  */
 void libhqr_print_dag( const libhqr_tree_t *qrtree,
                        const char          *filename );
 void libhqr_print_svg( const libhqr_tree_t *qrtree,
                        const char          *filename );
 
-/*
- * Debugging functions
+/**
+ * @}
+ * @name Checking/Debugging functions
+ * @{
+ */
+int  libhqr_check        ( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree );
+void libhqr_print_type   ( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree );
+void libhqr_print_pivot  ( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree );
+void libhqr_print_nbgeqrt( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree );
+void libhqr_print_perm   ( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int *perm );
+void libhqr_print_next_k ( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int k );
+void libhqr_print_prev_k ( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int k );
+void libhqr_print_geqrt_k( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int k );
+
+/**
+ * @}
  */
-int  libhqr_check        ( libhqr_matrix_t *A, libhqr_tree_t *qrtree );
-void libhqr_print_type   ( libhqr_matrix_t *A, libhqr_tree_t *qrtree );
-void libhqr_print_pivot  ( libhqr_matrix_t *A, libhqr_tree_t *qrtree );
-void libhqr_print_nbgeqrt( libhqr_matrix_t *A, libhqr_tree_t *qrtree );
-void libhqr_print_perm   ( libhqr_matrix_t *A, libhqr_tree_t *qrtree, int *perm );
-void libhqr_print_next_k ( libhqr_matrix_t *A, libhqr_tree_t *qrtree, int k );
-void libhqr_print_prev_k ( libhqr_matrix_t *A, libhqr_tree_t *qrtree, int k );
-void libhqr_print_geqrt_k( libhqr_matrix_t *A, libhqr_tree_t *qrtree, int k );
 
 END_C_DECLS
 
diff --git a/include/libhqr_common.h b/include/libhqr_common.h
deleted file mode 100644
index 1ae8a43..0000000
--- a/include/libhqr_common.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- * @file libhqr_common.h
- *
- * Header file for common macro
- *
- * @copyright 2017      Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
- *                      Univ. Bordeaux. All rights reserved.
- *
- * @version 1.0.0
- * @author Raphael Boucherie
- * @author Mathieu Faverge
- * @date 2017-04-05
- *
- */
-#ifndef _LIBHQR_COMMON_H_
-#define _LIBHQR_COMMON_H_
-
-#undef BEGIN_C_DECLS
-#undef END_C_DECLS
-#if defined(c_plusplus) || defined(__cplusplus)
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else
-# define BEGIN_C_DECLS          /* empty */
-# define END_C_DECLS            /* empty */
-#endif
-
-#endif /* _LIBHQR_COMMON_H_ */
diff --git a/include/libhqr_draw.h b/include/libhqr_draw.h
deleted file mode 100644
index 596151d..0000000
--- a/include/libhqr_draw.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
-  *
-  * @file libhqr_draw.h
-  *
-  * Header file for all the functions of drawing.
-  *
-  * @copyright 2017      Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
-  *                      Univ. Bordeaux. All rights reserved.
-  *
-  * @version 1.0.0
-  * @author Raphael Boucherie
-  * @author Mathieu Faverge
-  * @date 2017-04-04
-  *
-  **/
-
-#ifndef _LIBHQR_DRAW_H_
-#define _LIBHQR_DRAW_H_
-
-#include "libhqr_common.h"
-
-BEGIN_C_DECLS
-
-#define WIDTH  50
-#define HEIGHT 50
-#define SIZE   100
-
-/*
- * Clobal array for color
- */
-
-extern char *color[4];
-
-/*
- * function for treedraw
- */
-
-void libhqr_writeheader(FILE *file);
-void libhqr_writeend(FILE *file);
-void libhqr_drawTT(int x, int y, int w, int h, int k, FILE *file);
-void libhqr_drawTS(int x, int y, int w, int h, int k, FILE *file);
-void libhqr_drawline(int x1, int y1, int x2, int y2, int k, FILE *file);
-
-END_C_DECLS
-
-#endif /* _LIBHQR_DRAW_H_ */
diff --git a/include/libhqr_queue.h b/include/libhqr_queue.h
index 1448ce8..9c96890 100644
--- a/include/libhqr_queue.h
+++ b/include/libhqr_queue.h
@@ -16,10 +16,6 @@
 #ifndef _LIBHQR_QUEUE_H_
 #define _LIBHQR_QUEUE_H_
 
-#include "libhqr_common.h"
-
-BEGIN_C_DECLS
-
 typedef struct libhqr_queue_tile_s {
     struct libhqr_queue_tile_s *prev;
     struct libhqr_queue_tile_s *next;
@@ -27,11 +23,9 @@ typedef struct libhqr_queue_tile_s {
 } libhqr_queue_tile_t;
 
 libhqr_queue_tile_t *libhqr_queue_tile_new (void);
-void libhqr_queue_tile_push  (libhqr_queue_tile_t ** queue_tile, int numero);
-int  libhqr_queue_tile_head  (libhqr_queue_tile_t ** queue_tile);
-int  libhqr_queue_tile_pop   (libhqr_queue_tile_t ** queue_tile);
-void libhqr_queue_tile_delete(libhqr_queue_tile_t ** queue_tile);
-
-END_C_DECLS
+void libhqr_queue_tile_push  (libhqr_queue_tile_t **queue_tile, int numero);
+int  libhqr_queue_tile_head  (libhqr_queue_tile_t **queue_tile);
+int  libhqr_queue_tile_pop   (libhqr_queue_tile_t **queue_tile);
+void libhqr_queue_tile_delete(libhqr_queue_tile_t **queue_tile);
 
 #endif /* _LIBHQR_QUEUE_H_ */
diff --git a/lib/pkgconfig/libhqr.pc.in b/lib/pkgconfig/hqr.pc.in
similarity index 71%
rename from lib/pkgconfig/libhqr.pc.in
rename to lib/pkgconfig/hqr.pc.in
index 051384e..bf6d57a 100644
--- a/lib/pkgconfig/libhqr.pc.in
+++ b/lib/pkgconfig/hqr.pc.in
@@ -1,10 +1,11 @@
 prefix=@CMAKE_INSTALL_PREFIX@
 exec_prefix=${prefix}
 libdir=${exec_prefix}/lib
-includedir=${exec_prefix}/include/libhqr
+includedir=@INSTALL_HDR_DIR@
+#includdir=${exec_prefix}/include
 
-Name: libhqr
-Description: Build and Visualize Tree of Hierachical QR Factorization
+Name: HQR
+Description: Build and Visualize Trees for Hierachical QR Factorizations
 Version: @LIBHQR_VERSION_MAJOR@.@LIBHQR_VERSION_MINOR@.@LIBHQR_VERSION_MICRO@
 Cflags: -I${includedir}
 Libs: -L${libdir} @LIBHQR_PKGCONFIG_LIBS@
diff --git a/src/check.c b/src/check.c
index 9a477f2..e2d9dfb 100644
--- a/src/check.c
+++ b/src/check.c
@@ -30,7 +30,8 @@
         return ret;                             \
     }
 
-int libhqr_check( libhqr_matrix_t *A, libhqr_tree_t *qrtree)
+int
+libhqr_check( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree)
 {
     int minMN = libhqr_imin(A->mt, A->nt );
     int i, m, k, nb;
@@ -246,7 +247,8 @@ int libhqr_check( libhqr_matrix_t *A, libhqr_tree_t *qrtree)
     return 0;
 }
 
-void libhqr_print_type( libhqr_matrix_t *A, libhqr_tree_t *qrtree )
+void
+libhqr_print_type( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree )
 {
     int minMN = libhqr_imin(A->mt, A->nt );
     int m, k;
@@ -282,7 +284,8 @@ void libhqr_print_type( libhqr_matrix_t *A, libhqr_tree_t *qrtree )
     }
 }
 
-void libhqr_print_pivot( libhqr_matrix_t *A, libhqr_tree_t *qrtree )
+void
+libhqr_print_pivot( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree )
 {
     int minMN = libhqr_imin(A->mt, A->nt );
     int m, k;
@@ -317,7 +320,8 @@ void libhqr_print_pivot( libhqr_matrix_t *A, libhqr_tree_t *qrtree )
     }
 }
 
-void libhqr_print_next_k( libhqr_matrix_t *A, libhqr_tree_t *qrtree, int k )
+void
+libhqr_print_next_k( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int k )
 {
     int m, s;
     printf("\n------------ Next (k = %d)--------------\n", k);
@@ -336,7 +340,8 @@ void libhqr_print_next_k( libhqr_matrix_t *A, libhqr_tree_t *qrtree, int k )
     }
 }
 
-void libhqr_print_prev_k( libhqr_matrix_t *A, libhqr_tree_t *qrtree, int k )
+void
+libhqr_print_prev_k( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int k )
 {
     int m, s;
     printf("\n------------ Prev (k = %d)--------------\n", k);
@@ -355,7 +360,8 @@ void libhqr_print_prev_k( libhqr_matrix_t *A, libhqr_tree_t *qrtree, int k )
     }
 }
 
-void libhqr_print_perm( libhqr_matrix_t *A, libhqr_tree_t *qrtree, int *perm )
+void
+libhqr_print_perm( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int *perm )
 {
     int minMN = libhqr_imin(A->mt, A->nt );
     int m, k;
@@ -380,7 +386,8 @@ void libhqr_print_perm( libhqr_matrix_t *A, libhqr_tree_t *qrtree, int *perm )
     printf( "\n" );
 }
 
-void libhqr_print_nbgeqrt( libhqr_matrix_t *A, libhqr_tree_t *qrtree )
+void
+libhqr_print_nbgeqrt( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree )
 {
     int minMN = libhqr_imin(A->mt, A->nt );
     int m, k, nb;
@@ -408,7 +415,8 @@ void libhqr_print_nbgeqrt( libhqr_matrix_t *A, libhqr_tree_t *qrtree )
     printf( "\n" );
 }
 
-void libhqr_print_geqrt_k( libhqr_matrix_t *A, libhqr_tree_t *qrtree, int k )
+void
+libhqr_print_geqrt_k( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int k )
 {
     int i, m, nb;
     (void)A;
diff --git a/src/gensvg.c b/src/gensvg.c
index 63c1f36..6d52666 100644
--- a/src/gensvg.c
+++ b/src/gensvg.c
@@ -14,18 +14,20 @@
  *
  */
 #include "libhqr_internal.h"
-#include "libhqr_draw.h"
-#include "libhqr_queue.h"
 #include <stdio.h>
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
+#define WIDTH  50
+#define HEIGHT 50
+#define SIZE   100
+
 /*
  * Global array for color
  */
-
-char *colortree[4] = {"red", "blue", "green", "purple"};
+char *colortree[] = {"red", "blue", "green", "orange", "cyan", "purple", "yellow" };
+#define NBCOLORS (sizeof( colortree ) / sizeof( char* ))
 
 /*
  * functions writing in the svg file
@@ -50,7 +52,7 @@ static void
 drawsvg_top_TS( FILE *file, int k, int x, int y, int w, int h )
 {
     int rc;
-    rc = fprintf(file,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"%s\" /> \n", x, y, w, h, colortree[k%4]);
+    rc = fprintf(file,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"%s\" /> \n", x, y, w, h, colortree[k%NBCOLORS]);
 
     if (rc < 0) {
         fprintf(stderr, "Something wrong happened while writing the file (drawsvg_top_TS)\n");
@@ -63,7 +65,7 @@ drawsvg_bot_TS( FILE *file, int k, int x, int y, int w, int h )
 {
     int rc, x2, y2, w2, h2;
 
-    rc = fprintf(file,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"%s\" /> \n", x, y, w, h, colortree[k%4]);
+    rc = fprintf(file,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"%s\" /> \n", x, y, w, h, colortree[k%NBCOLORS]);
     if (rc < 0) {
         fprintf(stderr, "Something wrong happened while writing the file (drawsvg_bot_TS)\n");
         return;
@@ -86,7 +88,7 @@ drawsvg_top_TT( FILE *file, int k, int x, int y, int w, int h )
 {
     int rc;
     rc = fprintf( file,"<circle cx=\"%d\" cy=\"%d\" r=\"%d\" fill=\"%s\" /> \n",
-                  x + w / 2, y + h / 2, w / 2, colortree[k%4] );
+                  x + w / 2, y + h / 2, w / 2, colortree[k%NBCOLORS] );
     if (rc < 0) {
         fprintf(stderr, "Something wrong happened while writing the file (drawsvg_top_TT)\n");
     }
@@ -98,7 +100,7 @@ drawsvg_bot_TT( FILE *file, int k, int x, int y, int w, int h )
 {
     int rc;
     rc = fprintf( file,"<circle cx=\"%d\" cy=\"%d\" r=\"%d\" fill=\"%s\" /> \n",
-                  x + w / 2, y + h / 2, w / 2, colortree[k%4] );
+                  x + w / 2, y + h / 2, w / 2, colortree[k%NBCOLORS] );
     if (rc < 0) {
         fprintf(stderr, "Something wrong happened while writing the file (drawsvg_bot_TT)\n");
         return;
@@ -116,7 +118,7 @@ static void
 drawsvg_line( FILE *file, int k, int x1, int y1, int x2, int y2 )
 {
     int rc;
-    rc = fprintf(file,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\"fill:none;stroke:%s;stroke-width:2px;\"/> \n", x1, y1, x2, y2, colortree[k%4]);
+    rc = fprintf(file,"<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" style=\"fill:none;stroke:%s;stroke-width:2px;\"/> \n", x1, y1, x2, y2, colortree[k%NBCOLORS]);
 
     if (rc < 0) {
         fprintf(stderr, "Something wrong happened while writing the file (drawsvg_line)\n");
diff --git a/src/hqr.c b/src/hqr.c
index ee6bce4..1522aaf 100644
--- a/src/hqr.c
+++ b/src/hqr.c
@@ -321,7 +321,7 @@ hqr_currpiv(const libhqr_tree_t *qrtree, int k, int m)
             return gmt;
         }
     }
-};
+}
 
 /**
  *  hqr_nextpiv - Computes the next row killed by the row p, after
@@ -559,7 +559,7 @@ hqr_prevpiv(const libhqr_tree_t *qrtree, int k, int pivot, int start)
         default:
             return gmt;
         }
-};
+}
 
 /****************************************************
  *
@@ -659,6 +659,7 @@ hqr_getinvperm( const libhqr_tree_t *qrtree, int k, int m )
 
     /* We should never arrive here */
     myassert( 0 );
+    (void)k;
 }
 
 /**
diff --git a/src/queue.c b/src/queue.c
index eedec89..de36b91 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -2,7 +2,7 @@
  *
  * @file queue.c
  *
- * File for queue functions.
+ * Queue module for the treewalk algorithm.
  *
  * @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
  *                 Univ. Bordeaux. All rights reserved.
@@ -18,16 +18,14 @@
 #include <stdio.h>
 #include <assert.h>
 
-/****************************************************
- *   Generic functions for queue
- ***************************************************/
-
-libhqr_queue_tile_t *libhqr_queue_tile_new (void)
+libhqr_queue_tile_t *
+libhqr_queue_tile_new(void)
 {
    return (NULL);
 }
 
-void libhqr_queue_tile_push (libhqr_queue_tile_t ** queue_tile, int numero)
+void
+libhqr_queue_tile_push( libhqr_queue_tile_t **queue_tile, int numero )
 {
    if (queue_tile != NULL)
    {
@@ -55,7 +53,8 @@ void libhqr_queue_tile_push (libhqr_queue_tile_t ** queue_tile, int numero)
    return;
 }
 
-int libhqr_queue_tile_head (libhqr_queue_tile_t ** queue_tile)
+int
+libhqr_queue_tile_head( libhqr_queue_tile_t **queue_tile )
 {
    if (queue_tile != NULL && *queue_tile != NULL)
    {
@@ -64,7 +63,8 @@ int libhqr_queue_tile_head (libhqr_queue_tile_t ** queue_tile)
    return -1;
 }
 
-int libhqr_queue_tile_pop (libhqr_queue_tile_t ** queue_tile)
+int
+libhqr_queue_tile_pop ( libhqr_queue_tile_t **queue_tile )
 {
     int ret = -1;
     if (queue_tile != NULL)
@@ -82,4 +82,3 @@ int libhqr_queue_tile_pop (libhqr_queue_tile_t ** queue_tile)
     }
     return (ret);
 }
-
diff --git a/src/svd.c b/src/svd.c
index a7151a6..dd1b1a6 100644
--- a/src/svd.c
+++ b/src/svd.c
@@ -264,7 +264,7 @@ svd_currpiv(const libhqr_tree_t *qrtree, int k, int m)
         return gmt;
     }
     return -1;
-};
+}
 
 /**
  *  svd_nextpiv - Computes the next row killed by the row p, after
@@ -452,7 +452,7 @@ svd_prevpiv(const libhqr_tree_t *qrtree, int k, int pivot, int start)
     default:
         return gmt;
     }
-};
+}
 
 /**
  *******************************************************************************
diff --git a/testings/draw_hqr.c b/testings/draw_hqr.c
index 8054276..9f781b0 100644
--- a/testings/draw_hqr.c
+++ b/testings/draw_hqr.c
@@ -17,7 +17,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <libhqr.h>
-#include <libhqr_draw.h>
 #include "common.h"
 
 int
diff --git a/testings/draw_systolic.c b/testings/draw_systolic.c
index 2efcb79..72e944e 100644
--- a/testings/draw_systolic.c
+++ b/testings/draw_systolic.c
@@ -17,7 +17,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <libhqr.h>
-#include <libhqr_draw.h>
 #include "common.h"
 
 int
-- 
GitLab