Hi, On 06/18/2016 06:15 PM, Lazaros Koromilas wrote: >> What do you think of having: >> >> #define LOG_ERR() do { \ >> printf("test failed at %s():%d\n", __func__, __LINE__); \ >> } while (0) >> #define RET_ERR() do { LOG_ERR(); return -1; } while (0) >> #define GOTO_ERR() do { LOG_ERR(); ret = -1; goto out; } while (0) >> >> Then use GOTO_ERR() when appropriate. It would also factorize >> the printf. > > The downside of GOTO_ERR() is that it assumes a variable and a label > name. And you may need to have multiple labels 'out0', 'out1', etc for > the error path. How about: > > #define GOTO_ERR(ret, out) do { LOG_ERR(); ret = -1; goto out; } while (0)
Yep, looks better indeed. Thanks, Olivier