/*
- * test_dwarf.c
+ * SPDX-License-Identifier: GPL-2.0-only
*
- * Babeltrace bt_dwarf (DWARF utilities) tests
- *
- * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015 Antoine Busque <abusque@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; under version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Copyright (C) 2015 EfficiOS Inc. and Linux Foundation
+ * Copyright (C) 2015 Antoine Busque <abusque@efficios.com>
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * Babeltrace bt_dwarf (DWARF utilities) tests
*/
#include <fcntl.h>
Dwarf *dwarf_info = NULL;
path = g_build_filename(data_dir, ELF_DIR_NAME, SO_NAME, NULL);
- if (path == NULL) {
+ if (!path) {
diag("Failed to allocate memory for path");
exit(EXIT_FAILURE);
}
skip(1, "dwarf_begin failed as expected");
} else {
dwarf_info = dwarf_begin(fd, DWARF_C_READ);
- ok(dwarf_info == NULL, "dwarf_begin failed as expected");
+ ok(!dwarf_info, "dwarf_begin failed as expected");
}
- if (dwarf_info != NULL) {
+ if (dwarf_info) {
dwarf_end(dwarf_info);
}
- close(fd);
+
+ if (fd >= 0) {
+ close(fd);
+ }
g_free(path);
}
Dwarf *dwarf_info = NULL;
path = g_build_filename(data_dir, DWARF_DIR_NAME, SO_NAME, NULL);
- if (path == NULL) {
+ if (!path) {
diag("Failed to allocate memory for path");
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
dwarf_info = dwarf_begin(fd, DWARF_C_READ);
- ok(dwarf_info != NULL, "dwarf_begin successful");
+ ok(dwarf_info, "dwarf_begin successful");
cu = bt_dwarf_cu_create(dwarf_info);
- ok(cu != NULL, "bt_dwarf_cu_create successful");
+ ok(cu, "bt_dwarf_cu_create successful");
ret = bt_dwarf_cu_next(cu);
ok(ret == 0, "bt_dwarf_cu_next successful");
die = bt_dwarf_die_create(cu);
- ok(die != NULL, "bt_dwarf_die_create successful");
+ ok(die, "bt_dwarf_die_create successful");
if (!die) {
exit(EXIT_FAILURE);
}