Skip to content

Commit 5dce36e

Browse files
committed
Merge branch 'rs/remove-unused-find-header-mem'
Code clean-up. * rs/remove-unused-find-header-mem: commit: remove find_header_mem()
2 parents b8d1a1b + 28dc26d commit 5dce36e

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

commit.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,20 +1870,12 @@ struct commit_list **commit_list_append(struct commit *commit,
18701870
return &new_commit->next;
18711871
}
18721872

1873-
const char *find_header_mem(const char *msg, size_t len,
1874-
const char *key, size_t *out_len)
1873+
const char *find_commit_header(const char *msg, const char *key, size_t *out_len)
18751874
{
18761875
int key_len = strlen(key);
18771876
const char *line = msg;
18781877

1879-
/*
1880-
* NEEDSWORK: It's possible for strchrnul() to scan beyond the range
1881-
* given by len. However, current callers are safe because they compute
1882-
* len by scanning a NUL-terminated block of memory starting at msg.
1883-
* Nonetheless, it would be better to ensure the function does not look
1884-
* at msg beyond the len provided by the caller.
1885-
*/
1886-
while (line && line < msg + len) {
1878+
while (line) {
18871879
const char *eol = strchrnul(line, '\n');
18881880

18891881
if (line == eol)
@@ -1900,10 +1892,6 @@ const char *find_header_mem(const char *msg, size_t len,
19001892
return NULL;
19011893
}
19021894

1903-
const char *find_commit_header(const char *msg, const char *key, size_t *out_len)
1904-
{
1905-
return find_header_mem(msg, strlen(msg), key, out_len);
1906-
}
19071895
/*
19081896
* Inspect the given string and determine the true "end" of the log message, in
19091897
* order to find where to put a new Signed-off-by trailer. Ignored are

commit.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,17 +280,12 @@ void free_commit_extra_headers(struct commit_extra_header *extra);
280280

281281
/*
282282
* Search the commit object contents given by "msg" for the header "key".
283-
* Reads up to "len" bytes of "msg".
284283
* Returns a pointer to the start of the header contents, or NULL. The length
285284
* of the header, up to the first newline, is returned via out_len.
286285
*
287286
* Note that some headers (like mergetag) may be multi-line. It is the caller's
288287
* responsibility to parse further in this case!
289288
*/
290-
const char *find_header_mem(const char *msg, size_t len,
291-
const char *key,
292-
size_t *out_len);
293-
294289
const char *find_commit_header(const char *msg, const char *key,
295290
size_t *out_len);
296291

0 commit comments

Comments
 (0)