[babl] code style review
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] code style review
- Date: Sat, 25 May 2019 16:00:55 +0000 (UTC)
commit 9150f9cbb67d9dbd5e4794d9693ceb5b804708d5
Author: Nuno Ferreira <nuno360 gmail com>
Date: Tue Mar 26 07:59:15 2019 +0000
code style review
fixed style of function headers in the tools folder
tools/babl-benchmark.c | 4 +-
tools/babl-gen-test-pixels.c | 20 +++++++---
tools/babl-html-dump.c | 35 +++++++++++------
tools/babl-icc-dump.c | 85 ++++++++++++++++++++++++++++++++----------
tools/babl-icc-rewrite.c | 10 ++++-
tools/babl-verify.c | 4 +-
tools/babl_fish_path_fitness.c | 13 +++++--
tools/formats.c | 8 ++--
tools/trc-validator.c | 16 +++++---
9 files changed, 142 insertions(+), 53 deletions(-)
---
diff --git a/tools/babl-benchmark.c b/tools/babl-benchmark.c
index e7cec51..d3d95b0 100644
--- a/tools/babl-benchmark.c
+++ b/tools/babl-benchmark.c
@@ -34,7 +34,9 @@ int ITERATIONS = 2;
#define N_BYTES N_PIXELS * (4 * 8)
-static const char *unicode_hbar (int width, double fraction)
+static const char *
+unicode_hbar (int width,
+ double fraction)
{
static char ret[200]="";
const char *block[9]= {" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉","█"};
diff --git a/tools/babl-gen-test-pixels.c b/tools/babl-gen-test-pixels.c
index 9d4492e..7130e56 100644
--- a/tools/babl-gen-test-pixels.c
+++ b/tools/babl-gen-test-pixels.c
@@ -37,17 +37,21 @@
BABL_COMPONENT_FMT_STR ", " \
BABL_COMPONENT_FMT_STR
-static double rand_double (void)
+static double
+rand_double (void)
{
return (double) random () / RAND_MAX;
}
-static double rand_range_double (double min, double max)
+static double
+rand_range_double (double min,
+ double max)
{
return rand_double () * (max - min) + min;
}
-static void gen_path_pixels (void)
+static void
+gen_path_pixels (void)
{
int i;
srandom (20050728);
@@ -119,7 +123,8 @@ static void gen_path_pixels (void)
printf ("static const double *babl_format_test_pixels = babl_path_test_pixels;\n\n");
}
-static void gen_model_pixels (void)
+static void
+gen_model_pixels (void)
{
int i;
srandom (20050728);
@@ -141,7 +146,8 @@ static void gen_model_pixels (void)
printf ("};\n\n");
}
-static void gen_type_pixels (void)
+static void
+gen_type_pixels (void)
{
int i;
srandom (20050728);
@@ -163,7 +169,9 @@ static void gen_type_pixels (void)
printf ("};\n\n");
}
-int main (int argc, char **argv)
+int
+main (int argc,
+ char **argv)
{
printf (
"/* babl - dynamically extendable universal pixel conversion library.\n"
diff --git a/tools/babl-html-dump.c b/tools/babl-html-dump.c
index 4f59b4d..b685889 100644
--- a/tools/babl-html-dump.c
+++ b/tools/babl-html-dump.c
@@ -20,17 +20,29 @@
#include "config.h"
#include "babl-internal.h" /* needed for babl_log */
-static void model_html (Babl *babl);
-static void type_html (Babl *babl);
-static void format_html (Babl *babl);
-static void conversion_html (Babl *babl);
+static void
+model_html (Babl *babl);
-static int each_item (Babl *babl,
- void *user_data);
-static int show_item (Babl *babl,
- void *user_data);
-static int hide_item (Babl *babl,
- void *user_data);
+static void
+type_html (Babl *babl);
+
+static void
+format_html (Babl *babl);
+
+static void
+conversion_html (Babl *babl);
+
+static int
+each_item (Babl *babl,
+ void *user_data);
+
+static int
+ show_item (Babl *babl,
+ void *user_data);
+
+static int
+hide_item (Babl *babl,
+ void *user_data);
int
@@ -88,7 +100,8 @@ main (void)
static char normalized_buf[512];
-static const char *normalize (const char *str)
+static const char *
+normalize (const char *str)
{
char *s = normalized_buf;
diff --git a/tools/babl-icc-dump.c b/tools/babl-icc-dump.c
index 4b549ef..b90590b 100644
--- a/tools/babl-icc-dump.c
+++ b/tools/babl-icc-dump.c
@@ -22,7 +22,10 @@ typedef struct {
#define ICC_HEADER_LEN 128
#define TAG_COUNT_OFF ICC_HEADER_LEN
-static int load_u8 (const char *icc, int length, int offset)
+static int
+load_u8 (const char *icc,
+ int length,
+ int offset)
{
/* all reading functions take both the char *pointer and the length of the
* buffer, and all reads thus gets protected by this condition.
@@ -33,7 +36,10 @@ static int load_u8 (const char *icc, int length, int offset)
return *(uint8_t*) (&icc[offset]);
}
-static int load_s8 (const char *icc, int length, int offset)
+static int
+load_s8 (const char *icc,
+ int length,
+ int offset)
{
if (offset < 0 || offset > length)
return 0;
@@ -41,53 +47,74 @@ static int load_s8 (const char *icc, int length, int offset)
return *(int8_t*) (&icc[offset]);
}
-static int16_t load_u1f15 (const char *icc, int length, int offset)
+static int16_t
+load_u1f15 (const char *icc,
+ int length,
+ int offset)
{
return load_u8 (icc, length, offset + 1) +
(load_s8 (icc, length, offset + 0) << 8);
}
-static uint16_t load_u16 (const char *icc, int length, int offset)
+static uint16_t
+load_u16 (const char *icc,
+ int length,
+ int offset)
{
return load_u8 (icc, length, offset + 1) +
(load_u8 (icc, length, offset + 0) << 8);
}
-static u8f8_t load_u8f8_ (const char *icc, int length, int offset)
+static u8f8_t
+load_u8f8_ (const char *icc,
+ int length,
+ int offset)
{
u8f8_t ret ={load_u8 (icc, length, offset),
load_u8 (icc, length, offset + 1)};
return ret;
}
-static s15f16_t load_s15f16_ (const char *icc, int length, int offset)
+static s15f16_t
+load_s15f16_ (const char *icc,
+ int length,
+ int offset)
{
s15f16_t ret ={load_u1f15 (icc, length, offset),
load_u16 (icc, length, offset + 2)};
return ret;
}
-static double s15f16_to_d (s15f16_t fix)
+static double
+s15f16_to_d (s15f16_t fix)
{
return fix.integer + fix.fraction / 65535.0;
}
-static double u8f8_to_d (u8f8_t fix)
+static double
+u8f8_to_d (u8f8_t fix)
{
return fix.integer + fix.fraction / 255.0;
}
-static double load_s15f16 (const char *icc, int length, int offset)
+static double
+load_s15f16 (const char *icc,
+ int length,
+ int offset)
{
return s15f16_to_d (load_s15f16_ (icc, length, offset));
}
-static double load_u8f8 (const char *icc, int length, int offset)
+static double
+load_u8f8 (const char *icc,
+ int length,
+ int offset)
{
return u8f8_to_d (load_u8f8_ (icc, length, offset));
}
-static void print_u8f8 (u8f8_t fix)
+static void
+print_u8f8 (u8f8_t fix)
{
int i;
uint32_t foo;
@@ -101,7 +128,8 @@ static void print_u8f8 (u8f8_t fix)
}
}
-static void print_s15f16 (s15f16_t fix)
+static void
+print_s15f16 (s15f16_t fix)
{
int i;
uint32_t foo;
@@ -131,7 +159,10 @@ static void print_s15f16 (s15f16_t fix)
}
}
-static uint32_t load_u32 (const char *icc, int length, int offset)
+static uint32_t
+load_u32 (const char *icc,
+ int length,
+ int offset)
{
return load_u8 (icc, length, offset + 3) +
(load_u8 (icc, length, offset + 2) << 8) +
@@ -139,8 +170,11 @@ static uint32_t load_u32 (const char *icc, int length, int offset)
(load_u8 (icc, length, offset + 0) << 24);
}
-static void load_sign (const char *icc, int length,
- int offset, char *sign)
+static void
+load_sign (const char *icc,
+ int length,
+ int offset,
+ char *sign)
{
sign[0]=load_u8(icc, length, offset);
sign[1]=load_u8(icc, length, offset + 1);
@@ -151,8 +185,12 @@ static void load_sign (const char *icc, int length,
/* looks up offset and length for a specific icc tag
*/
-static int icc_tag (const char *icc, int length,
- const char *tag, int *offset, int *el_length)
+static int
+icc_tag (const char *icc,
+ int length,
+ const char *tag,
+ int *offset,
+ int *el_length)
{
int tag_count = load_u32 (icc, length, TAG_COUNT_OFF);
int t;
@@ -276,7 +314,10 @@ static int icc_tag (const char *icc, const char *tag, int *offset, int *length)
int exact = 0;
-static int load_icc_from_memory (const char *icc, long length, char **error)
+static int
+load_icc_from_memory (const char *icc,
+ long length,
+ char **error)
{
int tag_count = load_u32 (icc, length, TAG_COUNT_OFF);
int profile_size = load_u32 (icc, length, 0);
@@ -591,7 +632,9 @@ static int load_icc_from_memory (const char *icc, long length, char **error)
return 0;
}
-static int load_icc (const char *path, char **error)
+static int
+load_icc (const char *path,
+ char **error)
{
char *icc = NULL;
long length = 0;
@@ -643,7 +686,9 @@ file_get_contents (const char *path,
return 0;
}
-int main (int argc, char **argv)
+int
+main (int argc,
+ char **argv)
{
int i = 1;
if (argc < 2)
diff --git a/tools/babl-icc-rewrite.c b/tools/babl-icc-rewrite.c
index e91499a..5f87dc1 100644
--- a/tools/babl-icc-rewrite.c
+++ b/tools/babl-icc-rewrite.c
@@ -26,7 +26,10 @@ file_get_contents (const char *path,
long *length,
void *error);
-void file_set_contents (const char *path, const char *data, long length);
+void
+file_set_contents (const char *path,
+ const char *data,
+ long length);
int
main (int argc,
@@ -181,7 +184,10 @@ file_get_contents (const char *path,
return 0;
}
-void file_set_contents (const char *path, const char *data, long length)
+void
+file_set_contents (const char *path,
+ const char *data,
+ long length)
{
FILE *fp = fopen (path, "wb");
if (length == -1)
diff --git a/tools/babl-verify.c b/tools/babl-verify.c
index 2eaf0a3..8ac6b35 100644
--- a/tools/babl-verify.c
+++ b/tools/babl-verify.c
@@ -3,7 +3,9 @@
#include "../config.h"
#include "babl/babl-internal.h"
-int main (int argc, char **argv)
+int
+main (int argc,
+ char **argv)
{
int final = 0;
const Babl *fish;
diff --git a/tools/babl_fish_path_fitness.c b/tools/babl_fish_path_fitness.c
index 92c5935..9b0cfc5 100644
--- a/tools/babl_fish_path_fitness.c
+++ b/tools/babl_fish_path_fitness.c
@@ -62,17 +62,21 @@ static char test_pixels_in[NUM_TEST_PIXELS * 6 * 8];
static char test_pixels_out[NUM_TEST_PIXELS * 6 * 8];
-static double rand_double (void)
+static double
+rand_double (void)
{
return (double) random () / RAND_MAX;
}
-static double rand_range_double (double min, double max)
+static double
+rand_range_double (double min,
+ double max)
{
return rand_double () * (max - min) + min;
}
-static void init_test_pixels (void)
+static void
+init_test_pixels (void)
{
static int done = 0;
int i = 0;
@@ -227,7 +231,8 @@ static int source_each (Babl *babl,
return 0;
}
-int main (void)
+int
+main (void)
{
babl_init ();
diff --git a/tools/formats.c b/tools/formats.c
index 8f481bb..7f032ee 100644
--- a/tools/formats.c
+++ b/tools/formats.c
@@ -7,14 +7,16 @@
#include "babl-internal.h"
-static int format_check (Babl *babl,
- void *userdata)
+static int
+format_check (Babl *babl,
+ void *userdata)
{
babl_log ("%s\tloss: %f", babl->instance.name, babl->format.loss);
return 0;
}
-int main (void)
+int
+main (void)
{
babl_init ();
diff --git a/tools/trc-validator.c b/tools/trc-validator.c
index fffbe94..7bf1eaa 100644
--- a/tools/trc-validator.c
+++ b/tools/trc-validator.c
@@ -141,7 +141,8 @@ static inline float to_linear (float x)
#define DEGREE 6
#define SCALE 2
-static inline float from_linear (float x)
+static inline float
+from_linear (float x)
{
if (x >= X0 && x <= X1)
{
@@ -155,7 +156,8 @@ static inline float from_linear (float x)
return powf (x, 1.0f/GAMMA);
}
-static inline float to_linear (float x)
+static inline float
+to_linear (float x)
{
if (x >= X0 && x <= X1)
{
@@ -170,17 +172,21 @@ static inline float to_linear (float x)
}
#endif
-static inline float from_linear_ref (float x)
+static inline float
+from_linear_ref (float x)
{
return powf (x, 1.0/GAMMA);
}
-static inline float to_linear_ref (float x)
+static inline float
+to_linear_ref (float x)
{
return powf (x, GAMMA);
}
-int main (int argc, char **argv)
+int
+main (int argc,
+ char **argv)
{
int i;
float max_diff = 0.0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]