Simplify macros EFPRINTF and EFFLUSH. [0]
Also stdarg(3) says that each invocation of va_start() must be paired with a corresponding invocation of va_end() in the same function. [1] Reported by: Coverity CID: 1194318[0] and 1194332[1] Discussed with: jhb MFC after: 4 weeks. Sponsored by: iXsystems Inc. Differential Revision: https://reviews.freebsd.org/D15548
This commit is contained in:
parent
4c72d794f0
commit
6dd8233d5d
@ -118,18 +118,14 @@ struct basl_fio {
|
||||
};
|
||||
|
||||
#define EFPRINTF(...) \
|
||||
err = fprintf(__VA_ARGS__); if (err < 0) goto err_exit;
|
||||
if (fprintf(__VA_ARGS__) < 0) goto err_exit;
|
||||
|
||||
#define EFFLUSH(x) \
|
||||
err = fflush(x); if (err != 0) goto err_exit;
|
||||
if (fflush(x) != 0) goto err_exit;
|
||||
|
||||
static int
|
||||
basl_fwrite_rsdp(FILE *fp)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = 0;
|
||||
|
||||
EFPRINTF(fp, "/*\n");
|
||||
EFPRINTF(fp, " * bhyve RSDP template\n");
|
||||
EFPRINTF(fp, " */\n");
|
||||
@ -156,10 +152,6 @@ basl_fwrite_rsdp(FILE *fp)
|
||||
static int
|
||||
basl_fwrite_rsdt(FILE *fp)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = 0;
|
||||
|
||||
EFPRINTF(fp, "/*\n");
|
||||
EFPRINTF(fp, " * bhyve RSDT template\n");
|
||||
EFPRINTF(fp, " */\n");
|
||||
@ -196,10 +188,6 @@ basl_fwrite_rsdt(FILE *fp)
|
||||
static int
|
||||
basl_fwrite_xsdt(FILE *fp)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = 0;
|
||||
|
||||
EFPRINTF(fp, "/*\n");
|
||||
EFPRINTF(fp, " * bhyve XSDT template\n");
|
||||
EFPRINTF(fp, " */\n");
|
||||
@ -236,11 +224,8 @@ basl_fwrite_xsdt(FILE *fp)
|
||||
static int
|
||||
basl_fwrite_madt(FILE *fp)
|
||||
{
|
||||
int err;
|
||||
int i;
|
||||
|
||||
err = 0;
|
||||
|
||||
EFPRINTF(fp, "/*\n");
|
||||
EFPRINTF(fp, " * bhyve MADT template\n");
|
||||
EFPRINTF(fp, " */\n");
|
||||
@ -326,10 +311,6 @@ basl_fwrite_madt(FILE *fp)
|
||||
static int
|
||||
basl_fwrite_fadt(FILE *fp)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = 0;
|
||||
|
||||
EFPRINTF(fp, "/*\n");
|
||||
EFPRINTF(fp, " * bhyve FADT template\n");
|
||||
EFPRINTF(fp, " */\n");
|
||||
@ -547,10 +528,6 @@ basl_fwrite_fadt(FILE *fp)
|
||||
static int
|
||||
basl_fwrite_hpet(FILE *fp)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = 0;
|
||||
|
||||
EFPRINTF(fp, "/*\n");
|
||||
EFPRINTF(fp, " * bhyve HPET template\n");
|
||||
EFPRINTF(fp, " */\n");
|
||||
@ -596,8 +573,6 @@ basl_fwrite_hpet(FILE *fp)
|
||||
static int
|
||||
basl_fwrite_mcfg(FILE *fp)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
EFPRINTF(fp, "/*\n");
|
||||
EFPRINTF(fp, " * bhyve MCFG template\n");
|
||||
EFPRINTF(fp, " */\n");
|
||||
@ -629,10 +604,6 @@ basl_fwrite_mcfg(FILE *fp)
|
||||
static int
|
||||
basl_fwrite_facs(FILE *fp)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = 0;
|
||||
|
||||
EFPRINTF(fp, "/*\n");
|
||||
EFPRINTF(fp, " * bhyve FACS template\n");
|
||||
EFPRINTF(fp, " */\n");
|
||||
@ -666,7 +637,6 @@ void
|
||||
dsdt_line(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int err;
|
||||
|
||||
if (dsdt_error != 0)
|
||||
return;
|
||||
@ -675,8 +645,10 @@ dsdt_line(const char *fmt, ...)
|
||||
if (dsdt_indent_level != 0)
|
||||
EFPRINTF(dsdt_fp, "%*c", dsdt_indent_level * 2, ' ');
|
||||
va_start(ap, fmt);
|
||||
if (vfprintf(dsdt_fp, fmt, ap) < 0)
|
||||
if (vfprintf(dsdt_fp, fmt, ap) < 0) {
|
||||
va_end(ap);
|
||||
goto err_exit;
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
EFPRINTF(dsdt_fp, "\n");
|
||||
@ -735,9 +707,6 @@ dsdt_fixed_mem32(uint32_t base, uint32_t length)
|
||||
static int
|
||||
basl_fwrite_dsdt(FILE *fp)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = 0;
|
||||
dsdt_fp = fp;
|
||||
dsdt_error = 0;
|
||||
dsdt_indent_level = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user