mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 23:58:54 +02:00
kqueue: Fix -Wdeclaration-after-statement errors
https://bugzilla.gnome.org/show_bug.cgi?id=796213
This commit is contained in:
@@ -84,18 +84,22 @@ dep_list* dl_create (char *path, ino_t inode)
|
|||||||
dep_list*
|
dep_list*
|
||||||
dl_shallow_copy (const dep_list *dl)
|
dl_shallow_copy (const dep_list *dl)
|
||||||
{
|
{
|
||||||
|
dep_list *head;
|
||||||
|
dep_list *cp;
|
||||||
|
const dep_list *it;
|
||||||
|
|
||||||
if (dl == NULL) {
|
if (dl == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dep_list *head = calloc (1, sizeof (dep_list));
|
head = calloc (1, sizeof (dep_list));
|
||||||
if (head == NULL) {
|
if (head == NULL) {
|
||||||
perror_msg ("Failed to allocate head during shallow copy");
|
perror_msg ("Failed to allocate head during shallow copy");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dep_list *cp = head;
|
cp = head;
|
||||||
const dep_list *it = dl;
|
it = dl;
|
||||||
|
|
||||||
while (it != NULL) {
|
while (it != NULL) {
|
||||||
cp->path = it->path;
|
cp->path = it->path;
|
||||||
@@ -162,15 +166,19 @@ dl_free (dep_list *dl)
|
|||||||
dep_list*
|
dep_list*
|
||||||
dl_listing (const char *path)
|
dl_listing (const char *path)
|
||||||
{
|
{
|
||||||
assert (path != NULL);
|
|
||||||
|
|
||||||
dep_list *head = NULL;
|
dep_list *head = NULL;
|
||||||
dep_list *prev = NULL;
|
dep_list *prev = NULL;
|
||||||
DIR *dir = opendir (path);
|
DIR *dir;
|
||||||
|
|
||||||
|
assert (path != NULL);
|
||||||
|
|
||||||
|
dir = = opendir (path);
|
||||||
if (dir != NULL) {
|
if (dir != NULL) {
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
|
|
||||||
while ((ent = readdir (dir)) != NULL) {
|
while ((ent = readdir (dir)) != NULL) {
|
||||||
|
dep_list *iter;
|
||||||
|
|
||||||
if (!strcmp (ent->d_name, ".") || !strcmp (ent->d_name, "..")) {
|
if (!strcmp (ent->d_name, ".") || !strcmp (ent->d_name, "..")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -183,7 +191,7 @@ dl_listing (const char *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dep_list *iter = (prev == NULL) ? head : calloc (1, sizeof (dep_list));
|
iter = (prev == NULL) ? head : calloc (1, sizeof (dep_list));
|
||||||
if (iter == NULL) {
|
if (iter == NULL) {
|
||||||
perror_msg ("Failed to allocate a new element during listing");
|
perror_msg ("Failed to allocate a new element during listing");
|
||||||
goto error;
|
goto error;
|
||||||
@@ -229,6 +237,9 @@ error:
|
|||||||
void
|
void
|
||||||
dl_diff (dep_list **before, dep_list **after)
|
dl_diff (dep_list **before, dep_list **after)
|
||||||
{
|
{
|
||||||
|
dep_list *before_iter;
|
||||||
|
dep_list *before_prev;
|
||||||
|
|
||||||
assert (before != NULL);
|
assert (before != NULL);
|
||||||
assert (after != NULL);
|
assert (after != NULL);
|
||||||
|
|
||||||
@@ -236,12 +247,13 @@ dl_diff (dep_list **before, dep_list **after)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dep_list *before_iter = *before;
|
before_iter = *before;
|
||||||
dep_list *before_prev = NULL;
|
before_prev = NULL;
|
||||||
|
|
||||||
while (before_iter != NULL) {
|
while (before_iter != NULL) {
|
||||||
dep_list *after_iter = *after;
|
dep_list *after_iter = *after;
|
||||||
dep_list *after_prev = NULL;
|
dep_list *after_prev = NULL;
|
||||||
|
dep_list *oldptr;
|
||||||
|
|
||||||
int matched = 0;
|
int matched = 0;
|
||||||
while (after_iter != NULL) {
|
while (after_iter != NULL) {
|
||||||
@@ -266,7 +278,7 @@ dl_diff (dep_list **before, dep_list **after)
|
|||||||
after_iter = after_iter->next;
|
after_iter = after_iter->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
dep_list *oldptr = before_iter;
|
oldptr = before_iter;
|
||||||
before_iter = before_iter->next;
|
before_iter = before_iter->next;
|
||||||
if (matched == 0) {
|
if (matched == 0) {
|
||||||
before_prev = oldptr;
|
before_prev = oldptr;
|
||||||
@@ -283,17 +295,21 @@ dl_diff (dep_list **before, dep_list **after)
|
|||||||
* from the both lists.
|
* from the both lists.
|
||||||
**/
|
**/
|
||||||
#define EXCLUDE_SIMILAR(removed_list, added_list, match_expr, matched_code) \
|
#define EXCLUDE_SIMILAR(removed_list, added_list, match_expr, matched_code) \
|
||||||
|
G_STMT_START { \
|
||||||
|
dep_list *removed_list##_iter; \
|
||||||
|
dep_list *removed_list##_prev; \
|
||||||
|
int productive = 0; \
|
||||||
|
\
|
||||||
assert (removed_list != NULL); \
|
assert (removed_list != NULL); \
|
||||||
assert (added_list != NULL); \
|
assert (added_list != NULL); \
|
||||||
\
|
\
|
||||||
dep_list *removed_list##_iter = *removed_list; \
|
removed_list##_iter = *removed_list; \
|
||||||
dep_list *removed_list##_prev = NULL; \
|
removed_list##_prev = NULL; \
|
||||||
\
|
|
||||||
int productive = 0; \
|
|
||||||
\
|
\
|
||||||
while (removed_list##_iter != NULL) { \
|
while (removed_list##_iter != NULL) { \
|
||||||
dep_list *added_list##_iter = *added_list; \
|
dep_list *added_list##_iter = *added_list; \
|
||||||
dep_list *added_list##_prev = NULL; \
|
dep_list *added_list##_prev = NULL; \
|
||||||
|
dep_list *oldptr; \
|
||||||
\
|
\
|
||||||
int matched = 0; \
|
int matched = 0; \
|
||||||
while (added_list##_iter != NULL) { \
|
while (added_list##_iter != NULL) { \
|
||||||
@@ -317,7 +333,7 @@ dl_diff (dep_list **before, dep_list **after)
|
|||||||
} \
|
} \
|
||||||
added_list##_iter = added_list##_iter->next; \
|
added_list##_iter = added_list##_iter->next; \
|
||||||
} \
|
} \
|
||||||
dep_list *oldptr = removed_list##_iter; \
|
oldptr = removed_list##_iter; \
|
||||||
removed_list##_iter = removed_list##_iter->next; \
|
removed_list##_iter = removed_list##_iter->next; \
|
||||||
if (matched == 0) { \
|
if (matched == 0) { \
|
||||||
removed_list##_prev = oldptr; \
|
removed_list##_prev = oldptr; \
|
||||||
@@ -325,7 +341,8 @@ dl_diff (dep_list **before, dep_list **after)
|
|||||||
free (oldptr); \
|
free (oldptr); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
return (productive > 0);
|
return (productive > 0); \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
|
|
||||||
#define cb_invoke(cbs, name, udata, ...) \
|
#define cb_invoke(cbs, name, udata, ...) \
|
||||||
@@ -488,15 +505,14 @@ dl_calculate (dep_list *before,
|
|||||||
const traverse_cbs *cbs,
|
const traverse_cbs *cbs,
|
||||||
void *udata)
|
void *udata)
|
||||||
{
|
{
|
||||||
assert (cbs != NULL);
|
|
||||||
|
|
||||||
int need_update = 0;
|
int need_update = 0;
|
||||||
|
|
||||||
dep_list *was = dl_shallow_copy (before);
|
dep_list *was = dl_shallow_copy (before);
|
||||||
dep_list *pre = dl_shallow_copy (before);
|
dep_list *pre = dl_shallow_copy (before);
|
||||||
dep_list *now = dl_shallow_copy (after);
|
dep_list *now = dl_shallow_copy (after);
|
||||||
dep_list *lst = dl_shallow_copy (after);
|
dep_list *lst = dl_shallow_copy (after);
|
||||||
|
|
||||||
|
assert (cbs != NULL);
|
||||||
|
|
||||||
dl_diff (&was, &now);
|
dl_diff (&was, &now);
|
||||||
|
|
||||||
need_update += dl_detect_moves (&was, &now, cbs, udata);
|
need_update += dl_detect_moves (&was, &now, cbs, udata);
|
||||||
|
Reference in New Issue
Block a user