Skip to content

Commit 982f906

Browse files
danghaispbnick
authored andcommitted
Switch to using TLOG_ERRS_RAISE macros in .m4 files
1 parent b7487bb commit 982f906

File tree

4 files changed

+67
-149
lines changed

4 files changed

+67
-149
lines changed

lib/tlog/play_conf_cmd.c.m4

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,47 +66,36 @@ tlog_play_conf_cmd_load(struct tlog_errs **perrs,
6666
conf = json_object_new_object();
6767
if (conf == NULL) {
6868
grc = TLOG_GRC_ERRNO;
69-
tlog_errs_pushc(perrs, grc);
70-
tlog_errs_pushs(perrs, "Failed creating configuration object");
71-
goto cleanup;
69+
TLOG_ERRS_RAISECS(grc, "Failed creating configuration object");
7270
}
7371

7472
/* Extract program name */
7573
progpath = strdup(argv[0]);
7674
if (progpath == NULL) {
7775
grc = TLOG_GRC_ERRNO;
78-
tlog_errs_pushc(perrs, grc);
79-
tlog_errs_pushs(perrs, "Failed allocating a copy of program path");
80-
goto cleanup;
76+
TLOG_ERRS_RAISECS(grc, "Failed allocating a copy of program path");
8177
}
8278
progname = strdup(basename(progpath));
8379
if (progname == NULL) {
8480
grc = TLOG_GRC_ERRNO;
85-
tlog_errs_pushc(perrs, grc);
86-
tlog_errs_pushs(perrs, "Failed allocating program name");
87-
goto cleanup;
81+
TLOG_ERRS_RAISECS(grc, "Failed allocating program name");
8882
}
8983

9084
/* Extract options and positional arguments */
9185
if (asprintf(&help, tlog_play_conf_cmd_help_fmt, progname) < 0) {
9286
grc = TLOG_GRC_ERRNO;
93-
tlog_errs_pushc(perrs, grc);
94-
tlog_errs_pushs(perrs, "Failed formatting help message");
95-
goto cleanup;
87+
TLOG_ERRS_RAISECS(grc, "Failed formatting help message");
9688
}
9789
grc = tlog_play_conf_cmd_load_args(perrs, conf, help, argc, argv);
9890
if (grc != TLOG_RC_OK) {
99-
tlog_errs_pushs(perrs,
100-
"Failed extracting configuration "
101-
"from options and arguments");
102-
goto cleanup;
91+
TLOG_ERRS_RAISES("Failed extracting configuration "
92+
"from options and arguments");
10393
}
10494

10595
/* Validate the result */
10696
grc = tlog_play_conf_validate(perrs, conf, TLOG_CONF_ORIGIN_ARGS);
10797
if (grc != TLOG_RC_OK) {
108-
tlog_errs_pushs(perrs, "Validation of loaded configuration failed");
109-
goto cleanup;
98+
TLOG_ERRS_RAISES("Validation of loaded configuration failed");
11099
}
111100

112101
*phelp = help;

lib/tlog/rec_conf_cmd.c.m4

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,47 +66,36 @@ tlog_rec_conf_cmd_load(struct tlog_errs **perrs,
6666
conf = json_object_new_object();
6767
if (conf == NULL) {
6868
grc = TLOG_GRC_ERRNO;
69-
tlog_errs_pushc(perrs, grc);
70-
tlog_errs_pushs(perrs, "Failed creating configuration object");
71-
goto cleanup;
69+
TLOG_ERRS_RAISECS(grc, "Failed creating configuration object");
7270
}
7371

7472
/* Extract program name */
7573
progpath = strdup(argv[0]);
7674
if (progpath == NULL) {
7775
grc = TLOG_GRC_ERRNO;
78-
tlog_errs_pushc(perrs, grc);
79-
tlog_errs_pushs(perrs, "Failed allocating a copy of program path");
80-
goto cleanup;
76+
TLOG_ERRS_RAISECS(grc, "Failed allocating a copy of program path");
8177
}
8278
progname = strdup(basename(progpath));
8379
if (progname == NULL) {
8480
grc = TLOG_GRC_ERRNO;
85-
tlog_errs_pushc(perrs, grc);
86-
tlog_errs_pushs(perrs, "Failed allocating program name");
87-
goto cleanup;
81+
TLOG_ERRS_RAISECS(grc, "Failed allocating program name");
8882
}
8983

9084
/* Extract options and positional arguments */
9185
if (asprintf(&help, tlog_rec_conf_cmd_help_fmt, progname) < 0) {
9286
grc = TLOG_GRC_ERRNO;
93-
tlog_errs_pushc(perrs, grc);
94-
tlog_errs_pushs(perrs, "Failed formatting help message");
95-
goto cleanup;
87+
TLOG_ERRS_RAISECS(grc, "Failed formatting help message");
9688
}
9789
grc = tlog_rec_conf_cmd_load_args(perrs, conf, help, argc, argv);
9890
if (grc != TLOG_RC_OK) {
99-
tlog_errs_pushs(perrs,
100-
"Failed extracting configuration "
101-
"from options and arguments");
102-
goto cleanup;
91+
TLOG_ERRS_RAISES("Failed extracting configuration "
92+
"from options and arguments");
10393
}
10494

10595
/* Validate the result */
10696
grc = tlog_rec_conf_validate(perrs, conf, TLOG_CONF_ORIGIN_ARGS);
10797
if (grc != TLOG_RC_OK) {
108-
tlog_errs_pushs(perrs, "Validation of loaded configuration failed");
109-
goto cleanup;
98+
TLOG_ERRS_RAISES("Validation of loaded configuration failed");
11099
}
111100

112101
*phelp = help;

lib/tlog/rec_session_conf_cmd.c.m4

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,14 @@ tlog_rec_session_conf_cmd_load(struct tlog_errs **perrs,
7575
conf = json_object_new_object();
7676
if (conf == NULL) {
7777
grc = TLOG_GRC_ERRNO;
78-
tlog_errs_pushc(perrs, grc);
79-
tlog_errs_pushs(perrs, "Failed creating configuration object");
80-
goto cleanup;
78+
TLOG_ERRS_RAISECS(grc, "Failed creating configuration object");
8179
}
8280

8381
/* Get program path */
8482
progpath = strdup(argv[0]);
8583
if (progpath == NULL) {
8684
grc = TLOG_GRC_ERRNO;
87-
tlog_errs_pushc(perrs, grc);
88-
tlog_errs_pushs(perrs, "Failed allocating a copy of program path");
89-
goto cleanup;
85+
TLOG_ERRS_RAISECS(grc, "Failed allocating a copy of program path");
9086
}
9187

9288
/* Check for and extract login dash prefix */
@@ -96,15 +92,11 @@ tlog_rec_session_conf_cmd_load(struct tlog_errs **perrs,
9692
val = json_object_new_boolean(true);
9793
if (val == NULL) {
9894
grc = TLOG_GRC_ERRNO;
99-
tlog_errs_pushc(perrs, grc);
100-
tlog_errs_pushs(perrs, "Failed creating login flag");
101-
goto cleanup;
95+
TLOG_ERRS_RAISECS(grc, "Failed creating login flag");
10296
}
10397
grc = tlog_json_object_object_add_path(conf, "login", val);
10498
if (grc != TLOG_RC_OK) {
105-
tlog_errs_pushc(perrs, grc);
106-
tlog_errs_pushs(perrs, "Failed storing login flag");
107-
goto cleanup;
99+
TLOG_ERRS_RAISECS(grc, "Failed storing login flag");
108100
}
109101
val = NULL;
110102
}
@@ -121,11 +113,9 @@ tlog_rec_session_conf_cmd_load(struct tlog_errs **perrs,
121113
shell = strdup(shell_start);
122114
if (shell == NULL) {
123115
grc = TLOG_GRC_ERRNO;
124-
tlog_errs_pushc(perrs, grc);
125-
tlog_errs_pushs(perrs,
126-
"Failed allocating a copy of the shell part "
127-
"of the program name");
128-
goto cleanup;
116+
TLOG_ERRS_RAISECS(grc,
117+
"Failed allocating a copy of the shell part "
118+
"of the program name");
129119
}
130120
/* Decode and unescape the shell path */
131121
for (dst = src = shell; ;) {
@@ -143,15 +133,11 @@ tlog_rec_session_conf_cmd_load(struct tlog_errs **perrs,
143133
val = json_object_new_string(shell);
144134
if (val == NULL) {
145135
grc = TLOG_GRC_ERRNO;
146-
tlog_errs_pushc(perrs, grc);
147-
tlog_errs_pushs(perrs, "Failed creating shell path object");
148-
goto cleanup;
136+
TLOG_ERRS_RAISECS(grc, "Failed creating shell path object");
149137
}
150138
grc = tlog_json_object_object_add_path(conf, "shell", val);
151139
if (grc != TLOG_RC_OK) {
152-
tlog_errs_pushc(perrs, grc);
153-
tlog_errs_pushs(perrs, "Failed storing shell path");
154-
goto cleanup;
140+
TLOG_ERRS_RAISECS(grc, "Failed storing shell path");
155141
}
156142
val = NULL;
157143
}
@@ -160,31 +146,24 @@ tlog_rec_session_conf_cmd_load(struct tlog_errs **perrs,
160146
progname = strndup(progname_start, progname_end - progname_start);
161147
if (progname == NULL) {
162148
grc = TLOG_GRC_ERRNO;
163-
tlog_errs_pushc(perrs, grc);
164-
tlog_errs_pushs(perrs, "Failed allocating program name");
165-
goto cleanup;
149+
TLOG_ERRS_RAISECS(grc, "Failed allocating program name");
166150
}
167151

168152
/* Extract options and positional arguments */
169153
if (asprintf(&help, tlog_rec_session_conf_cmd_help_fmt, progname) < 0) {
170154
grc = TLOG_GRC_ERRNO;
171-
tlog_errs_pushc(perrs, grc);
172-
tlog_errs_pushs(perrs, "Failed formatting help message");
173-
goto cleanup;
155+
TLOG_ERRS_RAISECS(grc, "Failed formatting help message");
174156
}
175157
grc = tlog_rec_session_conf_cmd_load_args(perrs, conf, help, argc, argv);
176158
if (grc != TLOG_RC_OK) {
177-
tlog_errs_pushs(perrs,
178-
"Failed extracting configuration "
179-
"from options and arguments");
180-
goto cleanup;
159+
TLOG_ERRS_RAISES("Failed extracting configuration "
160+
"from options and arguments");
181161
}
182162

183163
/* Validate the result */
184164
grc = tlog_rec_session_conf_validate(perrs, conf, TLOG_CONF_ORIGIN_ARGS);
185165
if (grc != TLOG_RC_OK) {
186-
tlog_errs_pushs(perrs, "Validation of loaded configuration failed");
187-
goto cleanup;
166+
TLOG_ERRS_RAISES("Validation of loaded configuration failed");
188167
}
189168

190169
*phelp = help;

0 commit comments

Comments
 (0)