static int gera(struct declaracao *dec, char *filename)
{
FILE *f;
- int r;
+ int r = 0;
int i;
struct rendimento *rendimento;
struct isento *isento;
} while (0);
f = fopen(filename, "w");
- if (!f)
+ if (!f) {
+ r = -errno;
+ dec_set_error(dec, "Não foi possível abrir arquivo %s: %s.",
+ filename, strerror(errno));
goto out_file;
+ }
memset(dec->linhas, 0, sizeof(dec->linhas));
W(gera_header);
W(gera_contribuinte);
static int run_gera(struct declaracao *dec, char **args, int argc)
{
- if (argc != 2)
+ if (argc != 2) {
+ dec_set_error(dec, "Comando %s recebe um nome de arquivo como parâmetro.",
+ args[0]);
return -EINVAL;
- if (!ANO_VALIDO(dec->ano))
+ }
+ if (!ANO_VALIDO(dec->ano)) {
+ dec_set_error(dec, "Comando %s não suporta ano %d.",
+ args[0], dec->ano);
return -EINVAL;
+ }
return gera(dec, args[1]);
}