[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Synchronize .c and .h files



See commit message for details :)

One of these more usless commits, but it bothered me and I wanted to
check if there are other functions named differently in .c and .h.

Generated by doing:

$ for f in *.c; do grep '^\([^ ]\+ \)\+[^ ]\+(.*) {' "$f" | \
grep -v '^static' | sed 's/ {$/;/' | sort > "$f".fun; done

$ for f in *.h; do grep '(.*);' "$f" | sort > "$f".fun; done

And then comparing each foo.[ch].fun with vimdiff and doing some
filtering by hand. (Yes, it's quick & dirty)

Florian

-- 
() ascii ribbon campaign - stop html mail    www.asciiribbon.org
/\ www.the-compiler.org  | I love long mails http://email.is-not-s.ms/
"In the long run, every program becomes rococo, and then rubble." -- Alan 
Perlis 
From 3b2fd0d37bf973ad66d8558bb5702a5944e4459a Mon Sep 17 00:00:00 2001
From: Florian Bruhin <git _at_ the _minus_ compiler _dot_ org>
Date: Tue, 22 Oct 2013 06:55:53 +0200
Subject: [PATCH] Synchronize .c and .h files.

 - Adds "static" to functions which had static in the prototype but not
   in the function definition.

 - Adds "static" to some functions which didn't have it at all, but were
   not in the .h file.

 - Fixes naming of parameters so they are the same in the .c and the .h
   file.
---
 src/clientlist.c |  4 ++--
 src/command.c    | 14 +++++++-------
 src/ewmh.c       |  2 +-
 src/ipc-server.h |  2 +-
 src/monitor.c    |  2 +-
 src/object.c     |  6 +++---
 src/rules.c      | 28 ++++++++++++++--------------
 src/settings.c   |  2 +-
 src/stack.h      |  6 +++---
 src/utils.h      |  2 +-
 10 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/src/clientlist.c b/src/clientlist.c
index 8059282..f3d6b58 100644
--- a/src/clientlist.c
+++ b/src/clientlist.c
@@ -426,7 +426,7 @@ void client_setup_border(HSClient* client, bool focused) {
     }
 }
 
-void client_resize_fullscreen(HSClient* client, HSMonitor* m) {
+static void client_resize_fullscreen(HSClient* client, HSMonitor* m) {
     if (!client || !m) {
         HSDebug("client_resize_fullscreen() got invalid parameters\n");
         return;
@@ -650,7 +650,7 @@ void client_set_urgent(HSClient* client, bool state) {
     client_set_urgent_force(client, state);
 }
 
-void client_set_urgent_force(HSClient* client, bool state) {
+static void client_set_urgent_force(HSClient* client, bool state) {
     char winid_str[STRING_BUF_SIZE];
     snprintf(winid_str, STRING_BUF_SIZE, "0x%lx", client->window);
     hook_emit_list("urgent", state ? "on" : "off", winid_str, NULL);
diff --git a/src/command.c b/src/command.c
index 290bd51..e0b1e6a 100644
--- a/src/command.c
+++ b/src/command.c
@@ -633,7 +633,7 @@ void complete_against_keybinds(int argc, char** argv, int 
pos, GString* output)
     key_find_binds(needle, output);
 }
 
-bool parameter_expected(int argc, char** argv, int pos) {
+static bool parameter_expected(int argc, char** argv, int pos) {
     if (pos <= 0 || argc < 1) {
         /* no parameter if there is no command */
         return false;
@@ -861,7 +861,7 @@ void complete_sprintf(int argc, char** argv, int position, 
GString* output) {
     }
 }
 
-bool first_parameter_is_tag(int argc, char** argv, int pos) {
+static bool first_parameter_is_tag(int argc, char** argv, int pos) {
     // only complete if first parameter is a valid tag
     if (argc >= 2 && find_tag(argv[1]) && pos == 2) {
         return true;
@@ -870,7 +870,7 @@ bool first_parameter_is_tag(int argc, char** argv, int pos) 
{
     }
 }
 
-bool first_parameter_is_flag(int argc, char** argv, int pos) {
+static bool first_parameter_is_flag(int argc, char** argv, int pos) {
     // only complete if first parameter is a flag like -i or -e
     if (argc >= 2 && argv[1][0] == '-' && pos == 2) {
         return true;
@@ -879,7 +879,7 @@ bool first_parameter_is_flag(int argc, char** argv, int 
pos) {
     }
 }
 
-bool first_parameter_is_writable_attribute(int argc, char** argv, int pos) {
+static bool first_parameter_is_writable_attribute(int argc, char** argv, int 
pos) {
     GString* dummy = g_string_new("");
     HSAttribute* attr = NULL;
     if (argc >= 2) {
@@ -889,7 +889,7 @@ bool first_parameter_is_writable_attribute(int argc, char** 
argv, int pos) {
     return attr && attr->on_change != ATTR_READ_ONLY;
 }
 
-bool parameter_expected_offset(int argc, char** argv, int pos, int offset) {
+static bool parameter_expected_offset(int argc, char** argv, int pos, int 
offset) {
     if (argc < offset || pos < offset) {
         return true;
     }
@@ -900,11 +900,11 @@ bool parameter_expected_offset(int argc, char** argv, int 
pos, int offset) {
     return parameter_expected(argc - offset, argv + offset, pos - offset);
 }
 
-bool parameter_expected_offset_2(int argc, char** argv, int pos) {
+static bool parameter_expected_offset_2(int argc, char** argv, int pos) {
     return parameter_expected_offset(argc,argv, pos, 2);
 }
 
-bool parameter_expected_offset_3(int argc, char** argv, int pos) {
+static bool parameter_expected_offset_3(int argc, char** argv, int pos) {
     return parameter_expected_offset(argc,argv, pos, 3);
 }
 
diff --git a/src/ewmh.c b/src/ewmh.c
index 29f63b0..5a818f2 100644
--- a/src/ewmh.c
+++ b/src/ewmh.c
@@ -276,7 +276,7 @@ void ewmh_update_active_window(Window win) {
         XA_WINDOW, 32, PropModeReplace, (unsigned char*)&(win), 1);
 }
 
-bool focus_stealing_allowed(long source) {
+static bool focus_stealing_allowed(long source) {
     if (*g_focus_stealing_prevention) {
         /* only allow it to pagers/taskbars */
         return (source == 2);
diff --git a/src/ipc-server.h b/src/ipc-server.h
index fc3cb9e..11de995 100644
--- a/src/ipc-server.h
+++ b/src/ipc-server.h
@@ -12,7 +12,7 @@
 void ipc_init();
 void ipc_destroy();
 
-void ipc_add_connection(Window window);
+void ipc_add_connection(Window win);
 // returns true if property was received successfully
 bool ipc_handle_connection(Window window);
 bool is_ipc_connectable(Window window);
diff --git a/src/monitor.c b/src/monitor.c
index 95ab500..f824a45 100644
--- a/src/monitor.c
+++ b/src/monitor.c
@@ -223,7 +223,7 @@ static RectList* insert_rect_border(RectList* head,
 }
 
 // insert a new element without any intersections into the given list
-RectList* reclist_insert_disjoint(RectList* head, RectList* element) {
+static RectList* reclist_insert_disjoint(RectList* head, RectList* element) {
     if (!element) {
         return head;
     } else if (!head) {
diff --git a/src/object.c b/src/object.c
index 77a9b3f..cb08f1c 100644
--- a/src/object.c
+++ b/src/object.c
@@ -55,7 +55,7 @@ void hsobject_free(HSObject* obj) {
     g_list_free_full(obj->children, (GDestroyNotify)hsobjectchild_destroy);
 }
 
-void hsattribute_free(HSAttribute* attr) {
+static void hsattribute_free(HSAttribute* attr) {
     if (attr->user_data) {
         g_free(attr->name);
         if (attr->type == HSATTR_TYPE_STRING) {
@@ -88,14 +88,14 @@ void hsobject_unlink_and_destroy(HSObject* parent, 
HSObject* child) {
     hsobject_destroy(child);
 }
 
-HSObjectChild* hsobjectchild_create(char* name, HSObject* obj) {
+static HSObjectChild* hsobjectchild_create(char* name, HSObject* obj) {
     HSObjectChild* oc = g_new(HSObjectChild, 1);
     oc->name = g_strdup(name);
     oc->child = obj;
     return oc;
 }
 
-void hsobjectchild_destroy(HSObjectChild* oc) {
+static void hsobjectchild_destroy(HSObjectChild* oc) {
     if (!oc) return;
     g_free(oc->name);
     g_free(oc);
diff --git a/src/rules.c b/src/rules.c
index ce71f43..f4da9fb 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -108,7 +108,7 @@ void rules_destroy() {
 }
 
 // condition types //
-int find_condition_type(char* name) {
+static int find_condition_type(char* name) {
     char* cn;
     for (int i = 0; i < LENGTH(g_condition_types); i++) {
         cn = g_condition_types[i].name;
@@ -170,7 +170,7 @@ HSCondition* condition_create(int type, char op, char* 
value, GString* output) {
     return ptr;
 }
 
-void condition_destroy(HSCondition* cond) {
+static void condition_destroy(HSCondition* cond) {
     if (!cond) {
         return;
     }
@@ -192,7 +192,7 @@ void condition_destroy(HSCondition* cond) {
 }
 
 // consequence types //
-int find_consequence_type(char* name) {
+static int find_consequence_type(char* name) {
     char* cn;
     for (int i = 0; i < LENGTH(g_consequence_types); i++) {
         cn = g_consequence_types[i].name;
@@ -226,7 +226,7 @@ HSConsequence* consequence_create(int type, char op, char* 
value, GString* outpu
     return ptr;
 }
 
-void consequence_destroy(HSConsequence* cons) {
+static void consequence_destroy(HSConsequence* cons) {
     switch (cons->value_type) {
         case CONSEQUENCE_VALUE_TYPE_STRING:
             g_free(cons->value.str);
@@ -235,7 +235,7 @@ void consequence_destroy(HSConsequence* cons) {
     g_free(cons);
 }
 
-bool rule_label_replace(HSRule* rule, char op, char* value, GString* output) {
+static bool rule_label_replace(HSRule* rule, char op, char* value, GString* 
output) {
     switch (op) {
         case '=':
             if (*value == '\0') {
@@ -320,7 +320,7 @@ static gint rule_compare_label(const HSRule* a, const 
HSRule* b) {
 }
 
 // Looks up rules of a given label and removes them from the queue
-bool rule_find_pop(char* label) {
+static bool rule_find_pop(char* label) {
     GList* rule = { NULL };
     bool status = false; // Will be returned as true if any is found
     HSRule rule_find = { .label = label };
@@ -632,7 +632,7 @@ void rules_apply(HSClient* client, HSClientChanges* 
changes) {
 }
 
 /// CONDITIONS ///
-bool condition_string(HSCondition* rule, char* string) {
+static bool condition_string(HSCondition* rule, char* string) {
     if (!rule || !string) {
         return false;
     }
@@ -663,25 +663,25 @@ bool condition_string(HSCondition* rule, char* string) {
     return false;
 }
 
-bool condition_class(HSCondition* rule, HSClient* client) {
+static bool condition_class(HSCondition* rule, HSClient* client) {
     GString* window_class = window_class_to_g_string(g_display, 
client->window);
     bool match = condition_string(rule, window_class->str);
     g_string_free(window_class, true);
     return match;
 }
 
-bool condition_instance(HSCondition* rule, HSClient* client) {
+static bool condition_instance(HSCondition* rule, HSClient* client) {
     GString* inst = window_instance_to_g_string(g_display, client->window);
     bool match = condition_string(rule, inst->str);
     g_string_free(inst, true);
     return match;
 }
 
-bool condition_title(HSCondition* rule, HSClient* client) {
+static bool condition_title(HSCondition* rule, HSClient* client) {
     return condition_string(rule, client->title->str);
 }
 
-bool condition_pid(HSCondition* rule, HSClient* client) {
+static bool condition_pid(HSCondition* rule, HSClient* client) {
     if (client->pid < 0) {
         return false;
     }
@@ -694,12 +694,12 @@ bool condition_pid(HSCondition* rule, HSClient* client) {
     }
 }
 
-bool condition_maxage(HSCondition* rule, HSClient* client) {
+static bool condition_maxage(HSCondition* rule, HSClient* client) {
     time_t diff = get_monotonic_timestamp() - g_current_rule_birth_time;
     return (rule->value.integer >= diff);
 }
 
-bool condition_windowtype(HSCondition* rule, HSClient* client) {
+static bool condition_windowtype(HSCondition* rule, HSClient* client) {
     // that only works for atom-type utf8-string, _NET_WM_WINDOW_TYPE is int
     //  GString* wintype=
     //      window_property_to_g_string(g_display, client->window, 
wintype_atom);
@@ -751,7 +751,7 @@ bool condition_windowtype(HSCondition* rule, HSClient* 
client) {
     return false;
 }
 
-bool condition_windowrole(HSCondition* rule, HSClient* client) {
+static bool condition_windowrole(HSCondition* rule, HSClient* client) {
     GString* role = window_property_to_g_string(g_display, client->window,
         ATOM("WM_WINDOW_ROLE"));
     if (!role) return false;
diff --git a/src/settings.c b/src/settings.c
index afb4668..dfea7c5 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -211,7 +211,7 @@ int settings_toggle(int argc, char** argv, GString* output) 
{
     }
     return 0;
 }
-bool memberequals_settingspair(void* pmember, void* needle) {
+static bool memberequals_settingspair(void* pmember, void* needle) {
     char* str = *(char**)pmember;
     SettingsPair* pair = needle;
     if (pair->type == HS_Int) {
diff --git a/src/stack.h b/src/stack.h
index e2d8d3b..fca3168 100644
--- a/src/stack.h
+++ b/src/stack.h
@@ -61,10 +61,10 @@ void stack_insert_slice(HSStack* s, HSSlice* elem);
 void stack_remove_slice(HSStack* s, HSSlice* elem);
 void stack_raise_slide(HSStack* stack, HSSlice* slice);
 void stack_mark_dirty(HSStack* s);
-void stack_slice_add_layer(HSStack* s, HSSlice* slice, HSLayer layer);
-void stack_slice_remove_layer(HSStack* s, HSSlice* slice, HSLayer layer);
+void stack_slice_add_layer(HSStack* stack, HSSlice* slice, HSLayer layer);
+void stack_slice_remove_layer(HSStack* stack, HSSlice* slice, HSLayer layer);
 bool stack_is_layer_empty(HSStack* s, HSLayer layer);
-void stack_clear_layer(HSStack* s, HSLayer layer);
+void stack_clear_layer(HSStack* stack, HSLayer layer);
 
 int print_stack_command(int argc, char** argv, GString* output);
 
diff --git a/src/utils.h b/src/utils.h
index 7c64f67..c759011 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -71,7 +71,7 @@ void g_queue_remove_element(GQueue* queue, GList* elem);
 
 // find an element in an array buf with elems elements of size size.
 int array_find(void* buf, size_t elems, size_t size, void* needle);
-void array_reverse(void* buf, size_t elems, size_t size);
+void array_reverse(void* void_buf, size_t elems, size_t size);
 
 int min(int a, int b);
 
-- 
1.8.4.1

Attachment: pgpX5NnaO1EHs.pgp
Description: PGP signature