Skip to content

Commit 554fe20

Browse files
tihirvonJunio C Hamano
authored andcommitted
Make some strings const
Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 66eb64c commit 554fe20

File tree

11 files changed

+16
-15
lines changed

11 files changed

+16
-15
lines changed

builtin-mailinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static int handle_subject(char *line)
165165

166166
static int slurp_attr(const char *line, const char *name, char *attr)
167167
{
168-
char *ends, *ap = strcasestr(line, name);
168+
const char *ends, *ap = strcasestr(line, name);
169169
size_t sz;
170170

171171
if (!ap) {

builtin-rev-parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ int cmd_rev_parse(int argc, const char **argv, char **envp)
329329
dotdot = strstr(arg, "..");
330330
if (dotdot) {
331331
unsigned char end[20];
332-
char *next = dotdot + 2;
332+
const char *next = dotdot + 2;
333333
const char *this = arg;
334334
*dotdot = 0;
335335
if (!*next)

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ static int add_merge_info(enum cmit_fmt fmt, char *buf, const struct commit *com
543543
const char *hex = abbrev
544544
? find_unique_abbrev(p->object.sha1, abbrev)
545545
: sha1_to_hex(p->object.sha1);
546-
char *dots = (abbrev && strlen(hex) != 40) ? "..." : "";
546+
const char *dots = (abbrev && strlen(hex) != 40) ? "..." : "";
547547
parent = parent->next;
548548

549549
offset += sprintf(buf + offset, " %s%s", hex, dots);

connect.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static int git_tcp_connect_sock(char *host)
330330
{
331331
int sockfd = -1;
332332
char *colon, *end;
333-
char *port = STR(DEFAULT_GIT_PORT);
333+
const char *port = STR(DEFAULT_GIT_PORT);
334334
struct addrinfo hints, *ai0, *ai;
335335
int gai;
336336

@@ -525,7 +525,7 @@ static int git_use_proxy(const char *host)
525525
static void git_proxy_connect(int fd[2],
526526
const char *prog, char *host, char *path)
527527
{
528-
char *port = STR(DEFAULT_GIT_PORT);
528+
const char *port = STR(DEFAULT_GIT_PORT);
529529
char *colon, *end;
530530
int pipefd[2][2];
531531
pid_t pid;

daemon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static char *base_path = NULL;
3535
* after ~user/. E.g. a request to git://host/~alice/frotz would
3636
* go to /home/alice/pub_git/frotz with --user-path=pub_git.
3737
*/
38-
static char *user_path = NULL;
38+
static const char *user_path = NULL;
3939

4040
/* Timeout, and initial timeout */
4141
static unsigned int timeout = 0;
@@ -472,7 +472,7 @@ static void child_handler(int signo)
472472
children_reaped = reaped + 1;
473473
/* XXX: Custom logging, since we don't wanna getpid() */
474474
if (verbose) {
475-
char *dead = "";
475+
const char *dead = "";
476476
if (!WIFEXITED(status) || WEXITSTATUS(status) > 0)
477477
dead = " (with error)";
478478
if (log_syslog)

describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static int compare_names(const void *_a, const void *_b)
9797
return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
9898
}
9999

100-
static void describe(char *arg, int last_one)
100+
static void describe(const char *arg, int last_one)
101101
{
102102
unsigned char sha1[20];
103103
struct commit *cmit;

git.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
static void prepend_to_path(const char *dir, int len)
1818
{
19-
char *path, *old_path = getenv("PATH");
19+
const char *old_path = getenv("PATH");
20+
char *path;
2021
int path_len = len;
2122

2223
if (!old_path)

http-push.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ xml_cdata(void *userData, const XML_Char *s, int len)
12741274
strlcpy(ctx->cdata, s, len + 1);
12751275
}
12761276

1277-
static struct remote_lock *lock_remote(char *path, long timeout)
1277+
static struct remote_lock *lock_remote(const char *path, long timeout)
12781278
{
12791279
struct active_request_slot *slot;
12801280
struct slot_results results;
@@ -2130,7 +2130,7 @@ static int remote_exists(const char *path)
21302130
return -1;
21312131
}
21322132

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)
21342134
{
21352135
char *url;
21362136
struct buffer buffer;

imap-send.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ socket_read( Socket_t *sock, char *buf, int len )
242242
}
243243

244244
static int
245-
socket_write( Socket_t *sock, char *buf, int len )
245+
socket_write( Socket_t *sock, const char *buf, int len )
246246
{
247247
int n = write( sock->fd, buf, len );
248248
if (n != len) {

sha1_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static void read_info_alternates(const char * relative_base, int depth)
343343

344344
void prepare_alt_odb(void)
345345
{
346-
char *alt;
346+
const char *alt;
347347

348348
alt = getenv(ALTERNATE_DB_ENVIRONMENT);
349349
if (!alt) alt = "";

0 commit comments

Comments
 (0)