Skip to content

Commit

Permalink
Remove HDva_(arg|copy|end|start) (#3184)
Browse files Browse the repository at this point in the history
  • Loading branch information
derobins authored Jun 28, 2023
1 parent d278ce1 commit d81e751
Show file tree
Hide file tree
Showing 16 changed files with 205 additions and 220 deletions.
4 changes: 2 additions & 2 deletions src/H5E.c
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid
*/

/* Format the description */
HDva_start(ap, fmt);
va_start(ap, fmt);
va_started = TRUE;

/* Use the vasprintf() routine, since it does what we're trying to do below */
Expand All @@ -1345,7 +1345,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid

done:
if (va_started)
HDva_end(ap);
va_end(ap);
/* Memory was allocated with HDvasprintf so it needs to be freed
* with HDfree
*/
Expand Down
16 changes: 8 additions & 8 deletions src/H5ESint.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,16 @@ H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, con
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTINSERT, FAIL, "event set has failed operations")

/* Start working on the API routines arguments */
HDva_start(ap, caller_args);
va_start(ap, caller_args);
arg_started = TRUE;

/* Copy the app source information */
(void)HDva_arg(ap, char *); /* Toss the 'app_file' parameter name */
app_file = HDva_arg(ap, char *);
(void)HDva_arg(ap, char *); /* Toss the 'app_func' parameter name */
app_func = HDva_arg(ap, char *);
(void)HDva_arg(ap, char *); /* Toss the 'app_line' parameter name */
app_line = HDva_arg(ap, unsigned);
(void)va_arg(ap, char *); /* Toss the 'app_file' parameter name */
app_file = va_arg(ap, char *);
(void)va_arg(ap, char *); /* Toss the 'app_func' parameter name */
app_func = va_arg(ap, char *);
(void)va_arg(ap, char *); /* Toss the 'app_line' parameter name */
app_line = va_arg(ap, unsigned);

/* Create the string for the API routine's arguments */
if (NULL == (rs = H5RS_create(NULL)))
Expand All @@ -389,7 +389,7 @@ H5ES_insert(hid_t es_id, H5VL_t *connector, void *token, const char *caller, con
done:
/* Clean up */
if (arg_started)
HDva_end(ap);
va_end(ap);
if (rs)
H5RS_decr(rs);

Expand Down
4 changes: 2 additions & 2 deletions src/H5Eint.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin
*/

/* Start the variable-argument parsing */
HDva_start(ap, fmt);
va_start(ap, fmt);
va_started = TRUE;

/* Use the vasprintf() routine, since it does what we're trying to do below */
Expand All @@ -688,7 +688,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin

done:
if (va_started)
HDva_end(ap);
va_end(ap);
/* Memory was allocated with HDvasprintf so it needs to be freed
* with HDfree
*/
Expand Down
12 changes: 6 additions & 6 deletions src/H5RS.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,25 +373,25 @@ H5RS_asprintf_cat(H5RS_str_t *rs, const char *fmt, ...)
HGOTO_ERROR(H5E_RS, H5E_CANTINIT, FAIL, "can't initialize ref-counted string")

/* Attempt to write formatted output into the managed string */
HDva_start(args1, fmt);
HDva_copy(args2, args1);
va_start(args1, fmt);
va_copy(args2, args1);
while ((out_len = (size_t)HDvsnprintf(rs->end, (rs->max - rs->len), fmt, args1)) >= (rs->max - rs->len)) {
/* Allocate a large enough buffer */
if (H5RS__resize_for_append(rs, out_len) < 0)
HGOTO_ERROR(H5E_RS, H5E_CANTRESIZE, FAIL, "can't resize ref-counted string buffer")

/* Restart the va_list */
HDva_end(args1);
HDva_copy(args1, args2);
va_end(args1);
va_copy(args1, args2);
} /* end while */

/* Increment the size & end of the string */
rs->len += out_len;
rs->end += out_len;

/* Finish access to varargs */
HDva_end(args1);
HDva_end(args2);
va_end(args1);
va_end(args2);

done:
FUNC_LEAVE_NOAPI(ret_value)
Expand Down
12 changes: 0 additions & 12 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -1218,18 +1218,6 @@ H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap);
#endif
#endif

#ifndef HDva_arg
#define HDva_arg(A, T) va_arg(A, T)
#endif
#ifndef HDva_copy
#define HDva_copy(D, S) va_copy(D, S)
#endif
#ifndef HDva_end
#define HDva_end(A) va_end(A)
#endif
#ifndef HDva_start
#define HDva_start(A, P) va_start(A, P)
#endif
#ifndef HDvfprintf
#define HDvfprintf(F, FMT, A) vfprintf(F, FMT, A)
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/H5system.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ HDvasprintf(char **bufp, const char *fmt, va_list _ap)
int ret;
va_list ap;

HDva_copy(ap, _ap);
va_copy(ap, _ap);
ret = HDvsnprintf(buf, bufsz, fmt, ap);
va_end(ap);
if (ret >= 0 && (size_t)ret < bufsz) {
Expand Down Expand Up @@ -569,9 +569,9 @@ Wopen_utf8(const char *path, int oflag, ...)
if (oflag & O_CREAT) {
va_list vl;

HDva_start(vl, oflag);
pmode = HDva_arg(vl, int);
HDva_end(vl);
va_start(vl, oflag);
pmode = va_arg(vl, int);
va_end(vl);
}

/* Open the file */
Expand Down
Loading

0 comments on commit d81e751

Please sign in to comment.