# [PATCH 2/2] Disambiguate PREFIX define in sideband.c

4 messages from 2012-03-06 to 2012-03-06. Participants: Vincent van Ravesteijn, Junio C Hamano.
Thread: https://gitlist.dev/t/29854

## Vincent van Ravesteijn, 2012-03-06 08:54

Subject: [PATCH 1/2] Fix a warning about conversion to float
Message-ID: <1331024077-5736-1-git-send-email-user@vincent-VirtualBox>
URL: https://gitlist.dev/e/1331024077-5736-1-git-send-email-user%40vincent-VirtualBox

```
From: Vincent van Ravesteijn <vfr@lyx.org>

Below in the same function, val is correctly casted to a float. Do this also
for the initialization of x.

Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org>
---
 bisect.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/bisect.c b/bisect.c
index 6e186e2..4aeb402 100644
--- a/bisect.c
+++ b/bisect.c
@@ -536,7 +536,7 @@ static int get_prn(int count) {
  */
 static int sqrti(int val)
 {
-	float d, x = val;
+	float d, x = (float)val;
 
 	if (val == 0)
 		return 0;
@@ -550,6 +550,7 @@ static int sqrti(int val)
 	return (int)x;
 }
 
+
 static struct commit_list *skip_away(struct commit_list *list, int count)
 {
 	struct commit_list *cur, *previous;
-- 
1.7.5.4

```

## Vincent van Ravesteijn, 2012-03-06 08:54

Subject: [PATCH 2/2] Disambiguate PREFIX define in sideband.c
Message-ID: <1331024077-5736-2-git-send-email-user@vincent-VirtualBox>
URL: https://gitlist.dev/e/1331024077-5736-2-git-send-email-user%40vincent-VirtualBox
In-Reply-To: <1331024077-5736-1-git-send-email-user@vincent-VirtualBox>

```
From: Vincent van Ravesteijn <vfr@lyx.org>

PREFIX is already used as the prefix for the system path in system_path(..)
in exec_cmd.c. If PREFIX has been set, this patch prevents a warning that
PREFIX is being redefined.

Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org>
---
 sideband.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sideband.c b/sideband.c
index d5ffa1c..7c38fcb 100644
--- a/sideband.c
+++ b/sideband.c
@@ -12,7 +12,7 @@
  * the remote died unexpectedly.  A flush() concludes the stream.
  */
 
-#define PREFIX "remote:"
+#define SIDEBAND_PREFIX "remote:"
 
 #define ANSI_SUFFIX "\033[K"
 #define DUMB_SUFFIX "        "
@@ -21,13 +21,13 @@
 
 int recv_sideband(const char *me, int in_stream, int out)
 {
-	unsigned pf = strlen(PREFIX);
+	unsigned pf = strlen(SIDEBAND_PREFIX);
 	unsigned sf;
 	char buf[LARGE_PACKET_MAX + 2*FIX_SIZE];
 	char *suffix, *term;
 	int skip_pf = 0;
 
-	memcpy(buf, PREFIX, pf);
+	memcpy(buf, SIDEBAND_PREFIX, pf);
 	term = getenv("TERM");
 	if (term && strcmp(term, "dumb"))
 		suffix = ANSI_SUFFIX;
-- 
1.7.5.4

```

## Junio C Hamano, 2012-03-06 18:58

Subject: Re: [PATCH 1/2] Fix a warning about conversion to float
Message-ID: <7v62ehtv3l.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v62ehtv3l.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1331024077-5736-1-git-send-email-user@vincent-VirtualBox>

```
Vincent van Ravesteijn <vfr@lyx.org> writes:

> From: Vincent van Ravesteijn <vfr@lyx.org>
>
> Below in the same function, val is correctly casted to a float. Do this also
> for the initialization of x.

Hrm, is it correctly casted or needlessly casted?

It is unclear what problem you are trying to solve here.

> @@ -550,6 +550,7 @@ static int sqrti(int val)
>  	return (int)x;
>  }
>  
> +
>  static struct commit_list *skip_away(struct commit_list *list, int count)

Huh?

```

## Junio C Hamano, 2012-03-06 19:04

Subject: Re: [PATCH 2/2] Disambiguate PREFIX define in sideband.c
Message-ID: <7v1up5tut3.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v1up5tut3.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1331024077-5736-2-git-send-email-user@vincent-VirtualBox>

```
Vincent van Ravesteijn <vfr@lyx.org> writes:

> From: Vincent van Ravesteijn <vfr@lyx.org>
>
> PREFIX is already used as the prefix for the system path in system_path(..)
> in exec_cmd.c. If PREFIX has been set, this patch prevents a warning that
> PREFIX is being redefined.

If I recall correctly -DPREFIX= is given only when compiling that
single file in order to limit the knowledge of the actual value, and
is not given when compiling sideband.c, so it is unclear what
problem you are trying to solve here.

In any case, it probably makes sense to rename _both_ symbols to
make them more descriptive.  In the context of Makefile, PREFIX is
perfectly fine symbol to define the common prefix for installation
path (I would rather see it all in lowercase, but this dates back to
the very original Makefile by Linus), but in the context of the
whole source file, PREFIX doesn't not tell us what kind of prefix it
is about.

```
