MCPcopy Index your code
hub / github.com/git/git / fmt_with_err

Function fmt_with_err

usage.c:215–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215static const char *fmt_with_err(char *buf, int n, const char *fmt)
216{
217 char str_error[256], *err;
218 size_t i, j;
219
220 err = strerror(errno);
221 for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {
222 if ((str_error[j++] = err[i++]) != '%')
223 continue;
224 if (j < sizeof(str_error) - 1) {
225 str_error[j++] = '%';
226 } else {
227 /* No room to double the '%', so we overwrite it with
228 * '\0' below */
229 j--;
230 break;
231 }
232 }
233 str_error[j] = 0;
234 /* Truncation is acceptable here */
235 snprintf(buf, n, "%s: %s", fmt, str_error);
236 return buf;
237}
238
239void NORETURN die_errno(const char *fmt, ...)
240{

Callers 4

die_errnoFunction · 0.85
die_message_errnoFunction · 0.85
error_errnoFunction · 0.85
warning_errnoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected