@matheusbsbs / matheus-bagliano / commits / 554fe20d80
Fork 0

Make some strings const

Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Timo Hirvonen committed Jun 28, 2006 at 12:04 UTC 554fe20d805693d962bd41647c5dc075cf7f5261
11 files changed +16 -15
builtin-mailinfo.c
+1 -1
@@ -165,7 +165,7 @@ static int handle_subject(char *line)
165
166 static int slurp_attr(const char *line, const char *name, char *attr)
167 {
168 - char *ends, *ap = strcasestr(line, name);
168 + const char *ends, *ap = strcasestr(line, name);
169 size_t sz;
170
171 if (!ap) {
builtin-rev-parse.c
+1 -1
@@ -329,7 +329,7 @@ int cmd_rev_parse(int argc, const char **argv, char **envp)
329 dotdot = strstr(arg, "..");
330 if (dotdot) {
331 unsigned char end[20];
332 - char *next = dotdot + 2;
332 + const char *next = dotdot + 2;
333 const char *this = arg;
334 *dotdot = 0;
335 if (!*next)
commit.c
+1 -1
@@ -543,7 +543,7 @@ static int add_merge_info(enum cmit_fmt fmt, char *buf, const struct commit *com
543 const char *hex = abbrev
544 ? find_unique_abbrev(p->object.sha1, abbrev)
545 : sha1_to_hex(p->object.sha1);
546 - char *dots = (abbrev && strlen(hex) != 40) ? "..." : "";
546 + const char *dots = (abbrev && strlen(hex) != 40) ? "..." : "";
547 parent = parent->next;
548
549 offset += sprintf(buf + offset, " %s%s", hex, dots);
connect.c
+2 -2
@@ -330,7 +330,7 @@ static int git_tcp_connect_sock(char *host)
330 {
331 int sockfd = -1;
332 char *colon, *end;
333 - char *port = STR(DEFAULT_GIT_PORT);
333 + const char *port = STR(DEFAULT_GIT_PORT);
334 struct addrinfo hints, *ai0, *ai;
335 int gai;
336
@@ -525,7 +525,7 @@ static int git_use_proxy(const char *host)
525 static void git_proxy_connect(int fd[2],
526 const char *prog, char *host, char *path)
527 {
528 - char *port = STR(DEFAULT_GIT_PORT);
528 + const char *port = STR(DEFAULT_GIT_PORT);
529 char *colon, *end;
530 int pipefd[2][2];
531 pid_t pid;
daemon.c
+2 -2
@@ -35,7 +35,7 @@ static char *base_path = NULL;
35 * after ~user/. E.g. a request to git://host/~alice/frotz would
36 * go to /home/alice/pub_git/frotz with --user-path=pub_git.
37 */
38 -static char *user_path = NULL;
38 +static const char *user_path = NULL;
39
40 /* Timeout, and initial timeout */
41 static unsigned int timeout = 0;
@@ -472,7 +472,7 @@ static void child_handler(int signo)
472 children_reaped = reaped + 1;
473 /* XXX: Custom logging, since we don't wanna getpid() */
474 if (verbose) {
475 - char *dead = "";
475 + const char *dead = "";
476 if (!WIFEXITED(status) || WEXITSTATUS(status) > 0)
477 dead = " (with error)";
478 if (log_syslog)
describe.c
+1 -1
@@ -97,7 +97,7 @@ static int compare_names(const void *_a, const void *_b)
97 return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
98 }
99
100 -static void describe(char *arg, int last_one)
100 +static void describe(const char *arg, int last_one)
101 {
102 unsigned char sha1[20];
103 struct commit *cmit;
git.c
+2 -1
@@ -16,7 +16,8 @@
16
17 static void prepend_to_path(const char *dir, int len)
18 {
19 - char *path, *old_path = getenv("PATH");
19 + const char *old_path = getenv("PATH");
20 + char *path;
21 int path_len = len;
22
23 if (!old_path)
http-push.c
+2 -2
@@ -1274,7 +1274,7 @@ xml_cdata(void *userData, const XML_Char *s, int len)
1274 strlcpy(ctx->cdata, s, len + 1);
1275 }
1276
1277 -static struct remote_lock *lock_remote(char *path, long timeout)
1277 +static struct remote_lock *lock_remote(const char *path, long timeout)
1278 {
1279 struct active_request_slot *slot;
1280 struct slot_results results;
@@ -2130,7 +2130,7 @@ static int remote_exists(const char *path)
2130 return -1;
2131 }
2132
2133 -static void fetch_symref(char *path, char **symref, unsigned char *sha1)
2133 +static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
2134 {
2135 char *url;
2136 struct buffer buffer;
imap-send.c
+1 -1
@@ -242,7 +242,7 @@ socket_read( Socket_t *sock, char *buf, int len )
242 }
243
244 static int
245 -socket_write( Socket_t *sock, char *buf, int len )
245 +socket_write( Socket_t *sock, const char *buf, int len )
246 {
247 int n = write( sock->fd, buf, len );
248 if (n != len) {
sha1_file.c
+1 -1
@@ -343,7 +343,7 @@ static void read_info_alternates(const char * relative_base, int depth)
343
344 void prepare_alt_odb(void)
345 {
346 - char *alt;
346 + const char *alt;
347
348 alt = getenv(ALTERNATE_DB_ENVIRONMENT);
349 if (!alt) alt = "";
upload-pack.c
+2 -2
@@ -95,8 +95,8 @@ static void create_pack_file(void)
95 int i;
96 int args;
97 const char **argv;
98 + const char **p;
99 char *buf;
99 - char **p;
100
101 if (create_full_pack) {
102 args = 10;
@@ -441,7 +441,7 @@ static int receive_needs(void)
441
442 static int send_ref(const char *refname, const unsigned char *sha1)
443 {
444 - static char *capabilities = "multi_ack thin-pack side-band";
444 + static const char *capabilities = "multi_ack thin-pack side-band";
445 struct object *o = parse_object(sha1);
446
447 if (!o)