[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Findutils-patches] [PATCH] Don't return int to represent a boolean valu
From: |
James Youngman |
Subject: |
[Findutils-patches] [PATCH] Don't return int to represent a boolean value. |
Date: |
Sun, 4 Apr 2010 23:43:22 +0100 |
* find/defs.h: fd_leak_check_is_enabled should return boolean, not
int. Likewise following_links and digest_mode.
* lib/buildcmd.h: Likewise for bc_args_exceed_testing_limit.
Also #include <stdbool.h>.
* find/util.c (fd_leak_check_is_enabled): Now returns boolean.
* find/util.c (following_links): Likewise.
* find/util.c (digest_mode): Likewise.
* lib/buildcmd.c (bc_args_exceed_testing_limit): Likewise.
* find/find.c (get_current_dirfd): Indent definition correctly.
* find/util.c (get_start_dirfd): Likewise.
Signed-off-by: James Youngman <address@hidden>
---
ChangeLog | 12 ++++++++++++
find/defs.h | 6 +++---
find/find.c | 3 ++-
find/util.c | 23 ++++++++++++-----------
lib/buildcmd.c | 3 ++-
lib/buildcmd.h | 4 +++-
lib/regexprops.c | 3 ++-
lib/regextype.c | 3 ++-
8 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 709235a..31e4c84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2010-04-04 James Youngman <address@hidden>
+ Don't return int to represent a boolean value.
+ * find/defs.h: fd_leak_check_is_enabled should return boolean, not
+ int. Likewise following_links and digest_mode.
+ * lib/buildcmd.h: Likewise for bc_args_exceed_testing_limit.
+ Also #include <stdbool.h>.
+ * find/util.c (fd_leak_check_is_enabled): Now returns boolean.
+ * find/util.c (following_links): Likewise.
+ * find/util.c (digest_mode): Likewise.
+ * lib/buildcmd.c (bc_args_exceed_testing_limit): Likewise.
+ * find/find.c (get_current_dirfd): Indent definition correctly.
+ * find/util.c (get_start_dirfd): Likewise.
+
Fix Savannah bug #29435: fd_is_cloexec does not work on Fedora
buildhosts.
Fix open_cloexec on hosts which ignore O_CLOEXEC (i.e. old kernels).
diff --git a/find/defs.h b/find/defs.h
index f344f97..2d1d825 100644
--- a/find/defs.h
+++ b/find/defs.h
@@ -495,7 +495,7 @@ struct predicate *get_new_pred_chk_op PARAMS((const struct
parser_table *entry,
float calculate_derived_rates PARAMS((struct predicate *p));
/* util.c */
-int fd_leak_check_is_enabled (void);
+boolean fd_leak_check_is_enabled (void);
struct predicate *insert_primary PARAMS((const struct parser_table *entry,
const char *arg));
struct predicate *insert_primary_noarg PARAMS((const struct parser_table
*entry));
struct predicate *insert_primary_withpred PARAMS((const struct parser_table
*entry, PRED_FUNC fptr, const char *arg));
@@ -522,8 +522,8 @@ boolean apply_predicate(const char *pathname, struct stat
*stat_buf, struct pred
/* find.c. */
int get_info PARAMS((const char *pathname, struct stat *p, struct predicate
*pred_ptr));
-int following_links PARAMS((void));
-int digest_mode PARAMS((mode_t *mode, const char *pathname, const char *name,
struct stat *pstat, boolean leaf));
+boolean following_links PARAMS((void));
+boolean digest_mode PARAMS((mode_t *mode, const char *pathname, const char
*name, struct stat *pstat, boolean leaf));
boolean default_prints PARAMS((struct predicate *pred));
boolean looks_like_expression PARAMS((const char *arg, boolean leading));
diff --git a/find/find.c b/find/find.c
index 336e120..cc67c96 100644
--- a/find/find.c
+++ b/find/find.c
@@ -110,7 +110,8 @@ enum WdSanityCheckFatality
};
-int get_current_dirfd (void)
+int
+get_current_dirfd (void)
{
return AT_FDCWD;
}
diff --git a/find/util.c b/find/util.c
index 11e8eed..771ac42 100644
--- a/find/util.c
+++ b/find/util.c
@@ -451,13 +451,13 @@ undangle_file_pointers (struct predicate *p)
/* Return nonzero if file descriptor leak-checking is enabled.
*/
-int
+boolean
fd_leak_check_is_enabled (void)
{
if (getenv ("GNU_FINDUTILS_FD_LEAK_CHECK"))
- return 1;
+ return true;
else
- return 0;
+ return false;
}
@@ -656,25 +656,25 @@ debug_stat (const char *file, struct stat *bufp)
}
-int
+boolean
following_links(void)
{
switch (options.symlink_handling)
{
case SYMLINK_ALWAYS_DEREF:
- return 1;
+ return true;
case SYMLINK_DEREF_ARGSONLY:
return (state.curdepth == 0);
case SYMLINK_NEVER_DEREF:
default:
- return 0;
+ return false;
}
}
/* Take a "mode" indicator and fill in the files of 'state'.
*/
-int
+boolean
digest_mode (mode_t *mode,
const char *pathname,
const char *name,
@@ -690,7 +690,7 @@ digest_mode (mode_t *mode,
{
/* mode is wrong because we should have followed the symlink. */
if (get_statinfo (pathname, name, pstat) != 0)
- return 0;
+ return false;
*mode = state.type = pstat->st_mode;
state.have_type = true;
}
@@ -715,7 +715,7 @@ digest_mode (mode_t *mode,
else
{
if (get_statinfo (pathname, name, pstat) != 0)
- return 0;
+ return false;
/* If -L is in effect and we are dealing with a symlink,
* st_mode is the mode of the pointed-to file, while mode is
@@ -728,7 +728,7 @@ digest_mode (mode_t *mode,
}
/* success. */
- return 1;
+ return true;
}
@@ -1033,7 +1033,8 @@ set_option_defaults (struct options *p)
*
* Returns the fd for the directory we started in.
*/
-int get_start_dirfd (void)
+int
+get_start_dirfd (void)
{
return starting_desc;
}
diff --git a/lib/buildcmd.c b/lib/buildcmd.c
index 23fa528..0d7844e 100644
--- a/lib/buildcmd.c
+++ b/lib/buildcmd.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <wchar.h>
#include <locale.h>
+#include <stdbool.h>
#if ENABLE_NLS
# include <libintl.h>
@@ -683,7 +684,7 @@ exceeds (const char *env_var_name, size_t quantity)
}
/* Return nonzero if the indicated argument list exceeds a testing limit. */
-int
+bool
bc_args_exceed_testing_limit (const char **argv)
{
size_t chars, args;
diff --git a/lib/buildcmd.h b/lib/buildcmd.h
index faf4f67..95dcd71 100644
--- a/lib/buildcmd.h
+++ b/lib/buildcmd.h
@@ -20,6 +20,8 @@
#ifndef INC_BUILDCMD_H
#define INC_BUILDCMD_H 1
+#include <stdbool.h>
+
struct buildcmd_state
{
/* Number of valid elements in `cmd_argv', including terminating NULL. */
@@ -136,7 +138,7 @@ extern size_t bc_get_arg_max(void);
extern void bc_use_sensible_arg_max(struct buildcmd_control *ctl);
extern void bc_clear_args(const struct buildcmd_control *ctl,
struct buildcmd_state *state);
-extern int bc_args_exceed_testing_limit(const char **argv);
+bool bc_args_exceed_testing_limit(const char **argv);
#endif
diff --git a/lib/regexprops.c b/lib/regexprops.c
index 7facd0d..486fe02 100644
--- a/lib/regexprops.c
+++ b/lib/regexprops.c
@@ -561,7 +561,8 @@ describe_all (const char *contextname,
-int main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
const char *up = "";
unsigned int context = CONTEXT_ALL;
diff --git a/lib/regextype.c b/lib/regextype.c
index 5b391dd..e848811 100644
--- a/lib/regextype.c
+++ b/lib/regextype.c
@@ -138,7 +138,8 @@ unsigned int get_regex_type_context (unsigned int ix)
return 0u;
}
-int get_regex_type_synonym (unsigned int ix)
+int
+get_regex_type_synonym (unsigned int ix)
{
unsigned i;
int flags;
--
1.7.0
- [Findutils-patches] [PATCH] Don't return int to represent a boolean value.,
James Youngman <=