git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/02] ident.c: Use const qualifier when possible
@ 2007-04-15 18:51 Luiz Fernando N. Capitulino
  2007-04-15 20:06 ` Andy Parkins
  0 siblings, 1 reply; 4+ messages in thread
From: Luiz Fernando N. Capitulino @ 2007-04-15 18:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List


Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
---
 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 01/02] ident.c: Use const qualifier when possible
  2007-04-15 18:51 [PATCH 01/02] ident.c: Use const qualifier when possible Luiz Fernando N. Capitulino
@ 2007-04-15 20:06 ` Andy Parkins
  2007-04-15 20:14   ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Parkins @ 2007-04-15 20:06 UTC (permalink / raw)
  To: git; +Cc: Luiz Fernando N. Capitulino

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 01/02] ident.c: Use const qualifier when possible
  2007-04-15 20:06 ` Andy Parkins
@ 2007-04-15 20:14   ` Junio C Hamano
  2007-04-15 21:40     ` Luiz Fernando N. Capitulino
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2007-04-15 20:14 UTC (permalink / raw)
  To: Andy Parkins; +Cc: git, Luiz Fernando N. Capitulino

Andy Parkins <andyparkins@gmail.com> writes:

> On Sunday 2007, April 15, Luiz Fernando N. Capitulino wrote:
>
>> -static const char *env_hint =
>> +static const char const *env_hint =
>
> You can see then that
>
>  const char const *env_hint
>
> is redundant, it's simply saying twice that (*env_hint) is const.

I think he wanted to say

	static const char *const env_hint = ...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 01/02] ident.c: Use const qualifier when possible
  2007-04-15 20:14   ` Junio C Hamano
@ 2007-04-15 21:40     ` Luiz Fernando N. Capitulino
  0 siblings, 0 replies; 4+ messages in thread
From: Luiz Fernando N. Capitulino @ 2007-04-15 21:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Andy Parkins, git

Em Sun, 15 Apr 2007 13:14:57 -0700
Junio C Hamano <junkio@cox.net> escreveu:

| Andy Parkins <andyparkins@gmail.com> writes:
| 
| > On Sunday 2007, April 15, Luiz Fernando N. Capitulino wrote:
| >
| >> -static const char *env_hint =
| >> +static const char const *env_hint =
| >
| > You can see then that
| >
| >  const char const *env_hint
| >
| > is redundant, it's simply saying twice that (*env_hint) is const.
| 
| I think he wanted to say
| 
| 	static const char *const env_hint = ...

 Urgh, yes. And it's not possible to make the pointer const
because we change the value it points to (-2 for me).

 Updated version follows. I don't need to send the second
again, right?

From: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Subject: [PATCH] ident.c: Use const qualifier for 'struct passwd' parameters

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
---
 ident.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ident.c b/ident.c
index bb03bdd..b557ecd 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
-- 
1.5.1.1.86.gfd56-dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-04-15 21:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-15 18:51 [PATCH 01/02] ident.c: Use const qualifier when possible Luiz Fernando N. Capitulino
2007-04-15 20:06 ` Andy Parkins
2007-04-15 20:14   ` Junio C Hamano
2007-04-15 21:40     ` Luiz Fernando N. Capitulino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).