static int
testVirPCIVPDReadVPDBytes(const void *opaque G_GNUC_UNUSED)
{
- int fd = -1;
+ VIR_AUTOCLOSE fd = -1;
g_autofree uint8_t *buf = NULL;
uint8_t csum = 0;
size_t readBytes = 0;
static int
testVirPCIVPDParseVPDStringResource(const void *opaque G_GNUC_UNUSED)
{
- int fd = -1;
+ VIR_AUTOCLOSE fd = -1;
uint8_t csum = 0;
size_t dataLen = 0;
bool result = false;
return -1;
result = virPCIVPDParseVPDLargeResourceString(fd, 0, dataLen, &csum, res);
- VIR_FORCE_CLOSE(fd);
if (!result) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
static int
testVirPCIVPDParseFullVPD(const void *opaque G_GNUC_UNUSED)
{
- int fd = -1;
+ VIR_AUTOCLOSE fd = -1;
size_t dataLen = 0;
g_autoptr(virPCIVPDResource) res = NULL;
return -1;
res = virPCIVPDParse(fd);
- VIR_FORCE_CLOSE(fd);
if (!res) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
static int
testVirPCIVPDParseZeroLengthRW(const void *opaque G_GNUC_UNUSED)
{
- int fd = -1;
+ VIR_AUTOCLOSE fd = -1;
size_t dataLen = 0;
g_autoptr(virPCIVPDResource) res = NULL;
return -1;
res = virPCIVPDParse(fd);
- VIR_FORCE_CLOSE(fd);
if (!res) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
static int
testVirPCIVPDParseNoRW(const void *opaque G_GNUC_UNUSED)
{
- int fd = -1;
+ VIR_AUTOCLOSE fd = -1;
size_t dataLen = 0;
g_autoptr(virPCIVPDResource) res = NULL;
return -1;
res = virPCIVPDParse(fd);
- VIR_FORCE_CLOSE(fd);
if (!res) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
static int
testVirPCIVPDParseFullVPDSkipInvalidKeywords(const void *opaque G_GNUC_UNUSED)
{
- int fd = -1;
+ VIR_AUTOCLOSE fd = -1;
size_t dataLen = 0;
g_autoptr(virPCIVPDResource) res = NULL;
return -1;
res = virPCIVPDParse(fd);
- VIR_FORCE_CLOSE(fd);
if (!res) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
static int
testVirPCIVPDParseFullVPDSkipInvalidValues(const void *opaque G_GNUC_UNUSED)
{
- int fd = -1;
+ VIR_AUTOCLOSE fd = -1;
size_t dataLen = 0;
size_t i = 0;
virPCIVPDResourceCustom *custom = NULL;
return -1;
res = virPCIVPDParse(fd);
- VIR_FORCE_CLOSE(fd);
if (!res) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
static int
testVirPCIVPDParseFullVPDInvalid(const void *opaque G_GNUC_UNUSED)
{
- int fd = -1;
size_t dataLen = 0;
# define VPD_INVALID_ZERO_BYTE \
# define TEST_INVALID_VPD(invalidVPD) \
do { \
+ VIR_AUTOCLOSE fd = -1; \
g_autoptr(virPCIVPDResource) res = NULL; \
const uint8_t testCase[] = { invalidVPD }; \
dataLen = G_N_ELEMENTS(testCase); \
"Successfully parsed an invalid VPD - this is not expected"); \
return -1; \
} \
- VIR_FORCE_CLOSE(fd); \
} while (0);
TEST_INVALID_VPD(VPD_INVALID_ZERO_BYTE);