Re: [PATCH 1/3] usage.c: add BUG() function

2017-05-14 Thread Junio C Hamano
Jeff King writes: > On Fri, May 12, 2017 at 11:28:50PM -0400, Jeff King wrote: > >> +static NORETURN void BUG_vfl(const char *file, int line, const char *fmt, >> va_list params) >> +{ >> +char prefix[256]; >> + >> +/* truncation via snprintf is OK here */ >> +if (file) >> +

Re: [PATCH 1/3] usage.c: add BUG() function

2017-05-12 Thread Jeff King
On Fri, May 12, 2017 at 11:28:50PM -0400, Jeff King wrote: > +static NORETURN void BUG_vfl(const char *file, int line, const char *fmt, > va_list params) > +{ > + char prefix[256]; > + > + /* truncation via snprintf is OK here */ > + if (file) > + snprintf(prefix, sizeof(p

[PATCH 1/3] usage.c: add BUG() function

2017-05-12 Thread Jeff King
There's a convention in Git's code base to write assertions as: if (...some_bad_thing...) die("BUG: the terrible thing happened"); with the idea that users should never see a "BUG:" message (but if they, it at least gives a clue what happened). We use die() here because it's convenient