From 6d31193123ab5664d416853d6091f50f1a4aa004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Mon, 28 Oct 2019 23:55:22 +0100 Subject: [PATCH 1/2] Fix coding style in vector-operations.c --- geometric/vector-operations.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/geometric/vector-operations.c b/geometric/vector-operations.c index b236c3f..f3b0eb1 100644 --- a/geometric/vector-operations.c +++ b/geometric/vector-operations.c @@ -46,9 +46,10 @@ double vector_2d_scalar_multipy(struct vector_2d *a, struct vector_2d *b) void vector_2d_normalize(struct vector_2d *vec) { double len; + if (!vec) return; - len = sqrt(pow(vec->x,2)+pow(vec->y,2)); + len = sqrt(pow(vec->x, 2) + pow(vec->y, 2)); vec->x = vec->x/len; vec->y = vec->y/len; } @@ -97,9 +98,8 @@ struct vector_2d *vector_2d_alloc(void) void vector_2d_free(struct vector_2d *vec) { - if (vec) { + if (vec) free(vec); - } } void vector_2d_scale(struct vector_2d *vec, double scale) @@ -114,9 +114,9 @@ void vector_2d_scale(struct vector_2d *vec, double scale) double vector_2d_abs(struct vector_2d *vec) { double len = 0.0; - if (vec) { - len = sqrt(pow(vec->x,2)+pow(vec->y,2)); - } + + if (vec) + len = sqrt(pow(vec->x, 2) + pow(vec->y, 2)); return len; } @@ -142,7 +142,7 @@ void vector_2d_subtract(struct vector_2d *res, struct vector_2d *a, struct vecto void vector_2d_add(struct vector_2d *res, struct vector_2d *a, struct vector_2d *b) { if (res && a && b) { - res->x = a->x +b->x; + res->x = a->x + b->x; res->y = a->y + b->y; } } From 529b49ee2e0cf96bc5bf8471be8e876cbb1e2da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Mon, 28 Oct 2019 23:57:41 +0100 Subject: [PATCH 2/2] Fix coding style problems in bounding-box.c --- geometric/bounding-box.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/geometric/bounding-box.c b/geometric/bounding-box.c index 65dc781..3dc7d1e 100644 --- a/geometric/bounding-box.c +++ b/geometric/bounding-box.c @@ -33,8 +33,8 @@ #include -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) /**< @brief Return smaller number */ -#define MAX(a,b) (((a) > (b)) ? (a) : (b)) /**< @brief Return bigger number */ +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) /**< @brief Return smaller number */ +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) /**< @brief Return bigger number */ #define ABS_DBL(a) ((a) < 0 ? -(a) : (a)) void bounding_box_calculate_polygon(GList *vertices, conv_generic_to_vector_2d_t conv_func, union bounding_box *box) @@ -151,7 +151,7 @@ void bounding_box_calculate_path_box(GList *vertices, double thickness, GList *vertex_iterator; struct vector_2d pt; - printf("Warning! Function bounding_box_calculate_path_box not yet implemented correctly!\n"); + printf("Warning! Function %s not yet implemented correctly!\n", __func__); if (!vertices || !box) return;