[PATCH 01/02] ident.c: Use const qualifier when possible

Subsystems: the rest

DORMANTno replies

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH 01/02] ident.c: Use const qualifier when possible

From: Luiz Fernando N. Capitulino <hidden>
Date: 2016-06-15 22:43:04

Signed-off-by: Luiz Fernando N. Capitulino <redacted>
---
 ident.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/ident.c b/ident.c
index bb03bdd..454aace 100644
--- a/ident.c
+++ b/ident.c
@@ -9,7 +9,7 @@
 
 static char git_default_date[50];
 
-static void copy_gecos(struct passwd *w, char *name, int sz)
+static void copy_gecos(const struct passwd *w, char *name, int sz)
 {
 	char *src, *dst;
 	int len, nlen;
@@ -43,7 +43,7 @@ static void copy_gecos(struct passwd *w, char *name, int sz)
 
 }
 
-static void copy_email(struct passwd *pw)
+static void copy_email(const struct passwd *pw)
 {
 	/*
 	 * Make up a fake email address
@@ -172,7 +172,7 @@ static int copy(char *buf, int size, int offset, const char *src)
 
 static const char au_env[] = "GIT_AUTHOR_NAME";
 static const char co_env[] = "GIT_COMMITTER_NAME";
-static const char *env_hint =
+static const char const *env_hint =
 "\n"
 "*** Your name cannot be determined from your system services (gecos).\n"
 "\n"
-- 
1.5.1.1.86.gfd56-dirty

Re: [PATCH 01/02] ident.c: Use const qualifier when possible

From: Andy Parkins <hidden>
Date: 2016-06-15 22:43:04

On Sunday 2007, April 15, Luiz Fernando N. Capitulino wrote:
-static const char *env_hint =
+static const char const *env_hint =
 char c;              // c is a char
 char *p;             // p is a pointer, *p is a char
 const char c;        // c is a const char  [1]
 char const c;        // c is a const char  [1]
 const char *p;       // p is a pointer, *p is a const char [2]
 char const *p;       // p is a pointer, *p is a const char [2]
 char *const p;       // p is a const-pointer, *p is a char
 const char *const p; // p is a const-pointer, *p is a const-char

[1] Semantically identical
[2] Semantically identical

You can see then that

 const char const *env_hint

is redundant, it's simply saying twice that (*env_hint) is const.


Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help