Merge branch 'jk/snprintf-cleanups'
Code clean-up. * jk/snprintf-cleanups: daemon: use an argv_array to exec children gc: replace local buffer with git_path transport-helper: replace checked snprintf with xsnprintf convert unchecked snprintf into xsnprintf combine-diff: replace malloc/snprintf with xstrfmt replace unchecked snprintf calls with heap buffers receive-pack: print --pack-header directly into argv array name-rev: replace static buffer with strbuf create_branch: use xstrfmt for reflog message create_branch: move msg setup closer to point of use avoid using mksnpath for refs avoid using fixed PATH_MAX buffers for refs fetch: use heap buffer to format reflog tag: use strbuf to format tag header diff: avoid fixed-size buffer for patch-ids odb_mkstemp: use git_path_buf odb_mkstemp: write filename into strbuf do not check odb_mkstemp return value for errors
This commit is contained in:
@ -277,7 +277,7 @@ char *get_object_directory(void)
|
||||
return git_object_dir;
|
||||
}
|
||||
|
||||
int odb_mkstemp(char *template, size_t limit, const char *pattern)
|
||||
int odb_mkstemp(struct strbuf *template, const char *pattern)
|
||||
{
|
||||
int fd;
|
||||
/*
|
||||
@ -285,18 +285,16 @@ int odb_mkstemp(char *template, size_t limit, const char *pattern)
|
||||
* restrictive except to remove write permission.
|
||||
*/
|
||||
int mode = 0444;
|
||||
snprintf(template, limit, "%s/%s",
|
||||
get_object_directory(), pattern);
|
||||
fd = git_mkstemp_mode(template, mode);
|
||||
git_path_buf(template, "objects/%s", pattern);
|
||||
fd = git_mkstemp_mode(template->buf, mode);
|
||||
if (0 <= fd)
|
||||
return fd;
|
||||
|
||||
/* slow path */
|
||||
/* some mkstemp implementations erase template on failure */
|
||||
snprintf(template, limit, "%s/%s",
|
||||
get_object_directory(), pattern);
|
||||
safe_create_leading_directories(template);
|
||||
return xmkstemp_mode(template, mode);
|
||||
git_path_buf(template, "objects/%s", pattern);
|
||||
safe_create_leading_directories(template->buf);
|
||||
return xmkstemp_mode(template->buf, mode);
|
||||
}
|
||||
|
||||
int odb_pack_keep(const char *name)
|
||||
|
||||
Reference in New Issue
Block a user