From 4a39e94443339ca22d61e267f265b4b859591c2c Mon Sep 17 00:00:00 2001
From: Boris Stefanovic <owldev@bluewin.ch>
Date: Thu, 9 Jun 2022 16:45:03 +0200
Subject: [PATCH] CLEAN: compiles

---
 src/cluster.c |  2 ++
 src/common.c  |  2 +-
 src/common.h  |  2 ++
 src/io.c      |  3 +++
 src/main.c    | 12 +++++-------
 5 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/cluster.c b/src/cluster.c
index fbc62fb..504c930 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -8,6 +8,7 @@ cluster_int_t* cluster_create_int(vector_int_t* center) {
 	if (NULL == cluster) return NULL;
 	cluster->center = center;
 	cluster->points = list_points_create_int();
+	return cluster;
 }
 
 cluster_fpt_t* cluster_create_fpt(vector_fpt_t* center) {
@@ -15,6 +16,7 @@ cluster_fpt_t* cluster_create_fpt(vector_fpt_t* center) {
 	if (NULL == cluster) return NULL;
 	cluster->center = center;
 	cluster->points = list_points_create_fpt();
+	return cluster;
 }
 
 
diff --git a/src/common.c b/src/common.c
index d095459..f249bcd 100644
--- a/src/common.c
+++ b/src/common.c
@@ -7,7 +7,7 @@
 bool randinit = false;
 
 
-inline void init_rand() {
+void init_rand() {
 	srand(time(NULL));
 	randinit = true;
 }
diff --git a/src/common.h b/src/common.h
index 45cd812..c5a43aa 100644
--- a/src/common.h
+++ b/src/common.h
@@ -8,6 +8,8 @@ typedef int64_t int_t;
 typedef double fpt_t;
 
 
+void init_rand();
+
 int rand_int(int max);
 
 int rand_int_range(int min, int max);
diff --git a/src/io.c b/src/io.c
index d6cce4b..a3674bb 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1,5 +1,8 @@
+#define _GNU_SOURCE
+
 #include "io.h"
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include "linkedlist.h"
 #include "vector.h"
diff --git a/src/main.c b/src/main.c
index b350d46..c12fe2c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,10 +1,8 @@
-#define _GNU_SOURCE
-
+#include <getopt.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include "distance.h"
 #include "io.h"
 #include "kmeans.h"
@@ -77,12 +75,12 @@ int main_int(const char* ipath, const char* opath, const enum DistanceFunctionTy
 	FILE* ifile = ipath != NULL ? fopen(ipath, "r") : stdin;
 	const size_t dim = io_read_int(ifile);
 	const size_t nb_clusters = io_read_int(ifile);
-	if (0 <= dim) {
+	if (0 == dim) {
 		printf("DIMENSION MUST BE STRICTLY POSITIVE !\n");
 		fclose(ifile);
 		return EXIT_FAILURE;
 	}
-	if (0 <= nb_clusters) {
+	if (0 == nb_clusters) {
 		printf("NUMBER OF CLUSTERS MUST BE STRICTLY POSITIVE !\n");
 		fclose(ifile);
 		return EXIT_FAILURE;
@@ -110,12 +108,12 @@ int main_fpt(const char* ipath, const char* opath, const enum DistanceFunctionTy
 	FILE* ifile = ipath != NULL ? fopen(ipath, "r") : stdin;
 	const size_t dim = io_read_int(ifile);
 	const size_t nb_clusters = io_read_int(ifile);
-	if (0 <= dim) {
+	if (0 == dim) {
 		printf("DIMENSION MUST BE STRICTLY POSITIVE !\n");
 		fclose(ifile);
 		return EXIT_FAILURE;
 	}
-	if (0 <= nb_clusters) {
+	if (0 == nb_clusters) {
 		printf("NUMBER OF CLUSTERS MUST BE STRICTLY POSITIVE !\n");
 		fclose(ifile);
 		return EXIT_FAILURE;
-- 
GitLab