Page MenuHomeFreeBSD

Fix an uninitialized variable as well as an stdarg cleanup. (CID: 1194318 and 1194332)
ClosedPublic

Authored by araujo on May 24 2018, 4:58 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 17 2024, 9:01 PM
Unknown Object (File)
Dec 23 2023, 12:19 AM
Unknown Object (File)
Nov 12 2023, 12:15 PM
Unknown Object (File)
Sep 11 2023, 5:22 PM
Unknown Object (File)
Jul 3 2023, 7:37 AM
Unknown Object (File)
Jun 3 2023, 1:48 AM
Unknown Object (File)
May 14 2023, 6:26 AM
Unknown Object (File)
Apr 23 2023, 5:05 AM
Subscribers

Details

Summary

CID 1194318: We call the macro EFPRINTF without initialize the variable err.
CID 1194332: stdarg(3) says that each invocation of va_start() must be paired with a corresponding invocation of va_end() in the same function. In this case if an error occur with vfprintf() we forget to call va_end(ap).

Test Plan

Tested with FreeeBSD HEAD as a vm guest.
Tested with Fedora as a vm guest.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

So I looked at acpi.c and I have a couple of thoughts:

  1. style(9) discourages assignments in declarations and the rest of acpi.c follows that by setting err to 0 on separate lines
  1. But bigger than that, the whole 'err' variable isn't necessary. EFPRINTF should just be:
if (fprintf(__VA_ARGS__) < 0) goto err_exit;

Likewise, EFFLUSH should check the return value of fflush() directly. The spurious 'err' variables should then be removed.

Simplify both macros EFPRINTF and EFFLUSH and remove the unnecessary variable 'err'.
Likewise, remove varible 'err' from some functions that uses those two macros.

Thanks @jhb!

This revision was not accepted when it landed; it landed in state Needs Review.May 29 2018, 1:46 AM
This revision was automatically updated to reflect the committed changes.