I have a C function which calls other functions, each function returns int, where 0 is OK or error code if != 0. The function looks like:
int myfunc()
{
  int err;
  err = func1(arg1);
  if (err != 0) {
    return err;
  }
  err = func2(arg2, arg3);
  if (err != 0) {
    return err;
  }
  err = func3(arg4, arg5);
  if (err != 0) {
    return err;
  }
  err = func4();
  if (err != 0) {
    return err;
  }
  return 0;
}
As you can see I have a lot of boilerplate code:
err = some_func();
if (err != 0) {
  return err;
}
Is it possible to write some macros to simplify it? Something like:
#define TRY() ???
int myfunc()
{
  TRY(func1(arg1));
  TRY(func2(arg2, arg3));
  TRY(func3(arg4, arg5));
  TRY(func4());
}