[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/5] general: constify name/file funcs
From: |
Mike Frysinger |
Subject: |
[PATCH 2/5] general: constify name/file funcs |
Date: |
Thu, 11 Aug 2016 20:30:47 +0800 |
Noticed when looking into segfault. The "discarding const qualifier"
warning always makes me worried as it tends to come from bad code.
---
general.c | 26 +++++++++++++-------------
general.h | 18 +++++++++---------
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/general.c b/general.c
index 75dda55c3371..d1d37299f8d7 100644
--- a/general.c
+++ b/general.c
@@ -154,9 +154,9 @@ print_rlimtype (n, addnl)
/* Return non-zero if all of the characters in STRING are digits. */
int
all_digits (string)
- char *string;
+ const char *string;
{
- register char *s;
+ register const char *s;
for (s = string; *s; s++)
if (DIGIT (*s) == 0)
@@ -211,9 +211,9 @@ legal_number (string, result)
digit. */
int
legal_identifier (name)
- char *name;
+ const char *name;
{
- register char *s;
+ register const char *s;
unsigned char c;
if (!name || !(c = *name) || (legal_variable_starter (c) == 0))
@@ -234,7 +234,7 @@ legal_identifier (name)
not used in assignments. */
int
valid_nameref_value (name, flags)
- char *name;
+ const char *name;
int flags;
{
if (name == 0 || *name == 0)
@@ -265,7 +265,7 @@ check_selfref (name, value, flags)
#if defined (ARRAY_VARS)
if (valid_array_reference (value, 0))
{
- t = array_variable_name (value, (int *)NULL, (int *)NULL);
+ t = array_variable_name (value, NULL, NULL);
if (t && STREQ (name, t))
{
free (t);
@@ -309,7 +309,7 @@ check_identifier (word, check_word)
used yet. */
int
importable_function_name (string, len)
- char *string;
+ const char *string;
size_t len;
{
if (absolute_program (string)) /* don't allow slash */
@@ -323,7 +323,7 @@ importable_function_name (string, len)
int
exportable_function_name (string)
- char *string;
+ const char *string;
{
if (absolute_program (string))
return 0;
@@ -337,10 +337,10 @@ exportable_function_name (string)
parser (which disqualifies them from alias expansion anyway) and `/'. */
int
legal_alias_name (string, flags)
- char *string;
+ const char *string;
int flags;
{
- register char *s;
+ register const char *s;
for (s = string; *s; s++)
if (shellbreak (*s) || shellxquote (*s) || shellexp (*s) || (*s == '/'))
@@ -627,7 +627,7 @@ sh_closepipe (pv)
int
file_exists (fn)
- char *fn;
+ const char *fn;
{
struct stat sb;
@@ -636,7 +636,7 @@ file_exists (fn)
int
file_isdir (fn)
- char *fn;
+ const char *fn;
{
struct stat sb;
@@ -645,7 +645,7 @@ file_isdir (fn)
int
file_iswdir (fn)
- char *fn;
+ const char *fn;
{
return (file_isdir (fn) && sh_eaccess (fn, W_OK) == 0);
}
diff --git a/general.h b/general.h
index ba7e96878e57..645c8402772f 100644
--- a/general.h
+++ b/general.h
@@ -283,15 +283,15 @@ extern RLIMTYPE string_to_rlimtype __P((char *));
extern void print_rlimtype __P((RLIMTYPE, int));
#endif
-extern int all_digits __P((char *));
+extern int all_digits __P((const char *));
extern int legal_number __P((const char *, intmax_t *));
-extern int legal_identifier __P((char *));
-extern int importable_function_name __P((char *, size_t));
-extern int exportable_function_name __P((char *));
+extern int legal_identifier __P((const char *));
+extern int importable_function_name __P((const char *, size_t));
+extern int exportable_function_name __P((const char *));
extern int check_identifier __P((WORD_DESC *, int));
-extern int valid_nameref_value __P((char *, int));
+extern int valid_nameref_value __P((const char *, int));
extern int check_selfref __P((const char *, const char *, int));
-extern int legal_alias_name __P((char *, int));
+extern int legal_alias_name __P((const char *, int));
extern int assignment __P((const char *, int));
extern int sh_unset_nodelay_mode __P((int));
@@ -308,9 +308,9 @@ extern int same_file __P((char *, char *, struct stat *,
struct stat *));
extern int sh_openpipe __P((int *));
extern int sh_closepipe __P((int *));
-extern int file_exists __P((char *));
-extern int file_isdir __P((char *));
-extern int file_iswdir __P((char *));
+extern int file_exists __P((const char *));
+extern int file_isdir __P((const char *));
+extern int file_iswdir __P((const char *));
extern int path_dot_or_dotdot __P((const char *));
extern int absolute_pathname __P((const char *));
extern int absolute_program __P((const char *));
--
2.9.0