{"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
 "version": "2.1.0",
 "runs": [{"tool": {"driver": {"name": "GNU C99",
                               "fullName": "GNU C99 (GCC) version 16.1.1 20260703 (Red Hat 16.1.1-4) (x86_64-redhat-linux)",
                               "version": "16.1.1 20260703 (Red Hat 16.1.1-4)",
                               "informationUri": "https://gcc.gnu.org/gcc-16/",
                               "rules": [{"id": "-Wanalyzer-fd-leak",
                                          "helpUri": "https://gcc.gnu.org/onlinedocs/gcc-16.1.0/gcc/Static-Analyzer-Options.html#index-Wanalyzer-fd-leak"}]}},
           "taxonomies": [{"name": "CWE",
                           "version": "4.7",
                           "organization": "MITRE",
                           "shortDescription": {"text": "The MITRE Common Weakness Enumeration"},
                           "taxa": [{"id": "775",
                                     "helpUri": "https://cwe.mitre.org/data/definitions/775.html"}]}],
           "invocations": [{"arguments": ["/usr/libexec/gcc/x86_64-redhat-linux/16/cc1",
                                          "-quiet",
                                          "-I",
                                          ".",
                                          "-I",
                                          "./../../../include/",
                                          "-I",
                                          "./../",
                                          "-I",
                                          ".",
                                          "-I",
                                          "/usr/include/glib-2.0",
                                          "-I",
                                          "/usr/lib64/glib-2.0/include",
                                          "-I",
                                          "/usr/include/sysprof-6",
                                          "-I",
                                          "/usr/include/glib-2.0",
                                          "-I",
                                          "/usr/lib64/glib-2.0/include",
                                          "-I",
                                          "/usr/include/libmount",
                                          "-I",
                                          "/usr/include/blkid",
                                          "-I",
                                          "/usr/include/sysprof-6",
                                          "-I",
                                          "/usr/include/json-c",
                                          "-D",
                                          "PACKAGE_NAME=\"libblockdev\"",
                                          "-D",
                                          "PACKAGE_TARNAME=\"libblockdev\"",
                                          "-D",
                                          "PACKAGE_VERSION=\"3.4.0\"",
                                          "-D",
                                          "PACKAGE_STRING=\"libblockdev 3.4.0\"",
                                          "-D",
                                          "PACKAGE_BUGREPORT=\"\"",
                                          "-D",
                                          "PACKAGE_URL=\"https://github.com/storaged-project/libblockdev\"",
                                          "-D",
                                          "PACKAGE=\"libblockdev\"",
                                          "-D",
                                          "VERSION=\"3.4.0\"",
                                          "-D",
                                          "NDEBUG=1",
                                          "-D",
                                          "HAVE_STDIO_H=1",
                                          "-D",
                                          "HAVE_STDLIB_H=1",
                                          "-D",
                                          "HAVE_STRING_H=1",
                                          "-D",
                                          "HAVE_INTTYPES_H=1",
                                          "-D",
                                          "HAVE_STDINT_H=1",
                                          "-D",
                                          "HAVE_STRINGS_H=1",
                                          "-D",
                                          "HAVE_SYS_STAT_H=1",
                                          "-D",
                                          "HAVE_SYS_TYPES_H=1",
                                          "-D",
                                          "HAVE_UNISTD_H=1",
                                          "-D",
                                          "STDC_HEADERS=1",
                                          "-D",
                                          "HAVE_DLFCN_H=1",
                                          "-D",
                                          "LT_OBJDIR=\".libs/\"",
                                          "-D",
                                          "HAVE_DLFCN_H=1",
                                          "-D",
                                          "HAVE_STRING_H=1",
                                          "-D",
                                          "HAVE_UNISTD_H=1",
                                          "-D",
                                          "HAVE_SYS_FCNTL_H=1",
                                          "-D",
                                          "HAVE_SYS_IOCTL_H=1",
                                          "-D",
                                          "HAVE_LINUX_RANDOM_H=1",
                                          "-D",
                                          "HAVE_GLOB_H=1",
                                          "-D",
                                          "HAVE_SYSLOG_H=1",
                                          "-D",
                                          "HAVE_MATH_H=1",
                                          "-D",
                                          "WITH_BD_ESCROW=/**/",
                                          "-D",
                                          "WITH_BD_NVME=/**/",
                                          "-D",
                                          "WITH_BD_BTRFS=/**/",
                                          "-D",
                                          "WITH_BD_CRYPTO=/**/",
                                          "-D",
                                          "WITH_BD_DM=/**/",
                                          "-D",
                                          "WITH_BD_LOOP=/**/",
                                          "-D",
                                          "WITH_BD_LVM=/**/",
                                          "-D",
                                          "WITH_BD_LVM_DBUS=/**/",
                                          "-D",
                                          "WITH_BD_MDRAID=/**/",
                                          "-D",
                                          "WITH_BD_MPATH=/**/",
                                          "-D",
                                          "WITH_BD_SWAP=/**/",
                                          "-D",
                                          "WITH_BD_PART=/**/",
                                          "-D",
                                          "WITH_BD_FS=/**/",
                                          "-D",
                                          "WITH_BD_NVDIMM=/**/",
                                          "-D",
                                          "WITH_BD_NVME=/**/",
                                          "-D",
                                          "WITH_BD_SMART=/**/",
                                          "-D",
                                          "LIBCRYPTSETUP_24=1",
                                          "-D",
                                          "LIBCRYPTSETUP_26=1",
                                          "-D",
                                          "LIBCRYPTSETUP_27=1",
                                          "-D",
                                          "LIBCRYPTSETUP_28=1",
                                          "-D",
                                          "HAVE_LINUX_OPAL=1",
                                          "-D",
                                          "LIBMOUNT_NEW_ERR_API=1",
                                          "-D",
                                          "LIBNDCTL_NEW_MODES=1",
                                          "-D",
                                          "HAVE_LIBNVME_1_4=1",
                                          "-D",
                                          "HAVE_SMART=1",
                                          "-D",
                                          "HAVE_SMARTMONTOOLS=1",
                                          "-D",
                                          "PACKAGE_SYSCONF_DIR=\"/etc\"",
                                          "-D",
                                          "WITH_GZFILEOP",
                                          "-D",
                                          "PIC",
                                          "nvme-info.c",
                                          "-quiet",
                                          "-dumpbase",
                                          "nvme-info.c",
                                          "-dumpbase-ext",
                                          ".c",
                                          "-m64",
                                          "-mtune=generic",
                                          "-march=x86-64",
                                          "-mtls-dialect=gnu2",
                                          "-O2",
                                          "-Wno-unknown-pragmas",
                                          "-std=gnu99",
                                          "-flto=auto",
                                          "-ffat-lto-objects",
                                          "-fexceptions",
                                          "-fstack-protector-strong",
                                          "-fasynchronous-unwind-tables",
                                          "-fstack-clash-protection",
                                          "-fcf-protection=full",
                                          "-fno-omit-frame-pointer",
                                          "-fPIC",
                                          "-fanalyzer",
                                          "-fdiagnostics-path-format=separate-events",
                                          "-fno-diagnostics-show-caret",
                                          "-fno-lto",
                                          "-fanalyzer-assume-nothrow",
                                          "-fdiagnostics-text-art-charset=none",
                                          "-fdiagnostics-set-output=sarif:file=/builddir/gcc-results/6523-gcjG.sarif",
                                          "-o",
                                          "/tmp/cci9NoE3.s"],
                            "workingDirectory": {"uri": "/builddir/build/BUILD/libblockdev-3.4.0-build/libblockdev-3.4.0/src/plugins/nvme"},
                            "startTimeUtc": "2026-08-03T16:58:29Z",
                            "executionSuccessful": true,
                            "toolExecutionNotifications": [],
                            "endTimeUtc": "2026-08-03T16:58:30Z"}],
           "originalUriBaseIds": {"PWD": {"uri": "file:///builddir/build/BUILD/libblockdev-3.4.0-build/libblockdev-3.4.0/src/plugins/nvme/"}},
           "artifacts": [{"location": {"uri": "nvme-info.c",
                                       "uriBaseId": "PWD"},
                          "sourceLanguage": "c",
                          "contents": {"text": "/*\n * Copyright (C) 2014-2021 Red Hat, Inc.\n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public\n * License as published by the Free Software Foundation; either\n * version 2.1 of the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; if not, see <http://www.gnu.org/licenses/>.\n *\n * Author: Tomas Bzatek <tbzatek@redhat.com>\n */\n\n#include <glib.h>\n#include <string.h>\n#include <stdio.h>\n#include <unistd.h>\n#include <sys/ioctl.h>\n#include <sys/stat.h>\n#include <errno.h>\n#include <fcntl.h>\n#include <malloc.h>\n\n#include <libnvme.h>\n\n#include <blockdev/utils.h>\n#include <check_deps.h>\n#include \"nvme.h\"\n#include \"nvme-private.h\"\n\n\n/**\n * bd_nvme_controller_info_free: (skip)\n * @info: (nullable): %BDNVMEControllerInfo to free\n *\n * Frees @info.\n */\nvoid bd_nvme_controller_info_free (BDNVMEControllerInfo *info) {\n    if (info == NULL)\n        return;\n\n    g_free (info->fguid);\n    g_free (info->subsysnqn);\n    g_free (info->model_number);\n    g_free (info->serial_number);\n    g_free (info->firmware_ver);\n    g_free (info->nvme_ver);\n    g_free (info);\n}\n\n/**\n * bd_nvme_controller_info_copy: (skip)\n * @info: (nullable): %BDNVMEControllerInfo to copy\n *\n * Creates a new copy of @info.\n */\nBDNVMEControllerInfo * bd_nvme_controller_info_copy (BDNVMEControllerInfo *info) {\n    BDNVMEControllerInfo *new_info;\n\n    if (info == NULL)\n        return NULL;\n\n    new_info = g_new0 (BDNVMEControllerInfo, 1);\n    memcpy (new_info, info, sizeof (BDNVMEControllerInfo));\n    new_info->fguid = g_strdup (info->fguid);\n    new_info->subsysnqn = g_strdup (info->subsysnqn);\n    new_info->model_number = g_strdup (info->model_number);\n    new_info->serial_number = g_strdup (info->serial_number);\n    new_info->firmware_ver = g_strdup (info->firmware_ver);\n    new_info->nvme_ver = g_strdup (info->nvme_ver);\n\n    return new_info;\n}\n\n/**\n * bd_nvme_lba_format_free: (skip)\n * @fmt: (nullable): %BDNVMELBAFormat to free\n *\n * Frees @fmt.\n */\nvoid bd_nvme_lba_format_free (BDNVMELBAFormat *fmt) {\n    g_free (fmt);\n}\n\n/**\n * bd_nvme_lba_format_copy: (skip)\n * @fmt: (nullable): %BDNVMELBAFormat to copy\n *\n * Creates a new copy of @fmt.\n */\nBDNVMELBAFormat * bd_nvme_lba_format_copy (BDNVMELBAFormat *fmt) {\n    BDNVMELBAFormat *new_fmt;\n\n    if (fmt == NULL)\n        return NULL;\n\n    new_fmt = g_new0 (BDNVMELBAFormat, 1);\n    new_fmt->data_size = fmt->data_size;\n    new_fmt->metadata_size = fmt->metadata_size;\n    new_fmt->relative_performance = fmt->relative_performance;\n\n    return new_fmt;\n}\n\n/**\n * bd_nvme_namespace_info_free: (skip)\n * @info: (nullable): %BDNVMENamespaceInfo to free\n *\n * Frees @info.\n */\nvoid bd_nvme_namespace_info_free (BDNVMENamespaceInfo *info) {\n    BDNVMELBAFormat **lba_formats;\n\n    if (info == NULL)\n        return;\n\n    g_free (info->eui64);\n    g_free (info->uuid);\n    g_free (info->nguid);\n\n    for (lba_formats = info->lba_formats; lba_formats && *lba_formats; lba_formats++)\n        bd_nvme_lba_format_free (*lba_formats);\n    g_free (info->lba_formats);\n    g_free (info);\n}\n\n/**\n * bd_nvme_namespace_info_copy: (skip)\n * @info: (nullable): %BDNVMENamespaceInfo to copy\n *\n * Creates a new copy of @info.\n */\nBDNVMENamespaceInfo * bd_nvme_namespace_info_copy (BDNVMENamespaceInfo *info) {\n    BDNVMENamespaceInfo *new_info;\n    BDNVMELBAFormat **lba_formats;\n    GPtrArray *ptr_array;\n\n    if (info == NULL)\n        return NULL;\n\n    new_info = g_new0 (BDNVMENamespaceInfo, 1);\n    memcpy (new_info, info, sizeof (BDNVMENamespaceInfo));\n    new_info->eui64 = g_strdup (info->eui64);\n    new_info->uuid = g_strdup (info->uuid);\n    new_info->nguid = g_strdup (info->nguid);\n\n    ptr_array = g_ptr_array_new ();\n    for (lba_formats = info->lba_formats; lba_formats && *lba_formats; lba_formats++)\n        g_ptr_array_add (ptr_array, bd_nvme_lba_format_copy (*lba_formats));\n    g_ptr_array_add (ptr_array, NULL);\n    new_info->lba_formats = (BDNVMELBAFormat **) g_ptr_array_free (ptr_array, FALSE);\n\n    return new_info;\n}\n\n/**\n * bd_nvme_smart_log_free: (skip)\n * @log: (nullable): %BDNVMESmartLog to free\n *\n * Frees @log.\n */\nvoid bd_nvme_smart_log_free (BDNVMESmartLog *log) {\n    g_free (log);\n}\n\n/**\n * bd_nvme_smart_log_copy: (skip)\n * @log: (nullable): %BDNVMESmartLog to copy\n *\n * Creates a new copy of @log.\n */\nBDNVMESmartLog * bd_nvme_smart_log_copy (BDNVMESmartLog *log) {\n    BDNVMESmartLog *new_log;\n\n    if (log == NULL)\n        return NULL;\n\n    new_log = g_new0 (BDNVMESmartLog, 1);\n    memcpy (new_log, log, sizeof (BDNVMESmartLog));\n\n    return new_log;\n}\n\n/**\n * bd_nvme_error_log_entry_free: (skip)\n * @entry: (nullable): %BDNVMEErrorLogEntry to free\n *\n * Frees @entry.\n */\nvoid bd_nvme_error_log_entry_free (BDNVMEErrorLogEntry *entry) {\n    if (entry == NULL)\n        return;\n\n    if (entry->command_error)\n        g_error_free (entry->command_error);\n    g_free (entry);\n}\n\n/**\n * bd_nvme_error_log_entry_copy: (skip)\n * @entry: (nullable): %BDNVMEErrorLogEntry to copy\n *\n * Creates a new copy of @entry.\n */\nBDNVMEErrorLogEntry * bd_nvme_error_log_entry_copy (BDNVMEErrorLogEntry *entry) {\n    BDNVMEErrorLogEntry *new_entry;\n\n    if (entry == NULL)\n        return NULL;\n\n    new_entry = g_new0 (BDNVMEErrorLogEntry, 1);\n    memcpy (new_entry, entry, sizeof (BDNVMEErrorLogEntry));\n    if (entry->command_error)\n        new_entry->command_error = g_error_copy (entry->command_error);\n\n    return new_entry;\n}\n\n/**\n * bd_nvme_self_test_log_entry_free: (skip)\n * @entry: (nullable): %BDNVMESelfTestLogEntry to free\n *\n * Frees @entry.\n */\nvoid bd_nvme_self_test_log_entry_free (BDNVMESelfTestLogEntry *entry) {\n    if (entry == NULL)\n        return;\n\n    if (entry->status_code_error)\n        g_error_free (entry->status_code_error);\n    g_free (entry);\n}\n\n/**\n * bd_nvme_self_test_log_entry_copy: (skip)\n * @entry: (nullable): %BDNVMESelfTestLogEntry to copy\n *\n * Creates a new copy of @entry.\n */\nBDNVMESelfTestLogEntry * bd_nvme_self_test_log_entry_copy (BDNVMESelfTestLogEntry *entry) {\n    BDNVMESelfTestLogEntry *new_entry;\n\n    if (entry == NULL)\n        return NULL;\n\n    new_entry = g_new0 (BDNVMESelfTestLogEntry, 1);\n    memcpy (new_entry, entry, sizeof (BDNVMESelfTestLogEntry));\n    if (entry->status_code_error)\n        new_entry->status_code_error = g_error_copy (entry->status_code_error);\n\n    return new_entry;\n}\n\n/**\n * bd_nvme_self_test_result_to_string:\n * @result: A %BDNVMESelfTestResult.\n * @error: (out) (optional): place to store error (if any)\n *\n * Returns: (transfer none): A string representation of @result for use as an identifier string\n *                           or %NULL when the code is unknown.\n */\nconst gchar * bd_nvme_self_test_result_to_string (BDNVMESelfTestResult result, GError **error) {\n    static const gchar * const str[] = {\n        [BD_NVME_SELF_TEST_RESULT_NO_ERROR] = \"success\",\n        [BD_NVME_SELF_TEST_RESULT_ABORTED] = \"aborted\",\n        [BD_NVME_SELF_TEST_RESULT_CTRL_RESET] = \"ctrl_reset\",\n        [BD_NVME_SELF_TEST_RESULT_NS_REMOVED] = \"ns_removed\",\n        [BD_NVME_SELF_TEST_RESULT_ABORTED_FORMAT] = \"aborted_format\",\n        [BD_NVME_SELF_TEST_RESULT_FATAL_ERROR] = \"fatal_error\",\n        [BD_NVME_SELF_TEST_RESULT_UNKNOWN_SEG_FAIL] = \"unknown_seg_fail\",\n        [BD_NVME_SELF_TEST_RESULT_KNOWN_SEG_FAIL] = \"known_seg_fail\",\n        [BD_NVME_SELF_TEST_RESULT_ABORTED_UNKNOWN] = \"aborted_unknown\",\n        [BD_NVME_SELF_TEST_RESULT_ABORTED_SANITIZE] = \"aborted_sanitize\"\n    };\n\n    if (result >= G_N_ELEMENTS (str)) {\n        g_set_error (error, BD_NVME_ERROR, BD_NVME_ERROR_INVALID_ARGUMENT,\n                     \"Invalid result code %d\", result);\n        return NULL;\n    }\n\n    return str[result];\n}\n\n/**\n * bd_nvme_self_test_log_free: (skip)\n * @log: (nullable): %BDNVMESelfTestLog to free\n *\n * Frees @log.\n */\nvoid bd_nvme_self_test_log_free (BDNVMESelfTestLog *log) {\n    BDNVMESelfTestLogEntry **entries;\n\n    if (log == NULL)\n        return;\n\n    for (entries = log->entries; entries && *entries; entries++)\n        bd_nvme_self_test_log_entry_free (*entries);\n    g_free (log->entries);\n    g_free (log);\n}\n\n/**\n * bd_nvme_self_test_log_copy: (skip)\n * @log: (nullable): %BDNVMESelfTestLog to copy\n *\n * Creates a new copy of @log.\n */\nBDNVMESelfTestLog * bd_nvme_self_test_log_copy (BDNVMESelfTestLog *log) {\n    BDNVMESelfTestLog *new_log;\n    BDNVMESelfTestLogEntry **entries;\n    GPtrArray *ptr_array;\n\n    if (log == NULL)\n        return NULL;\n\n    new_log = g_new0 (BDNVMESelfTestLog, 1);\n    memcpy (new_log, log, sizeof (BDNVMESelfTestLog));\n\n    ptr_array = g_ptr_array_new ();\n    for (entries = log->entries; entries && *entries; entries++)\n        g_ptr_array_add (ptr_array, bd_nvme_self_test_log_entry_copy (*entries));\n    g_ptr_array_add (ptr_array, NULL);\n    new_log->entries = (BDNVMESelfTestLogEntry **) g_ptr_array_free (ptr_array, FALSE);\n\n    return new_log;\n}\n\n\n/**\n * bd_nvme_sanitize_log_free: (skip)\n * @log: (nullable): %BDNVMESanitizeLog to free\n *\n * Frees @log.\n */\nvoid bd_nvme_sanitize_log_free (BDNVMESanitizeLog *log) {\n    if (log == NULL)\n        return;\n\n    g_free (log);\n}\n\n/**\n * bd_nvme_sanitize_log_copy: (skip)\n * @log: (nullable): %BDNVMESanitizeLog to copy\n *\n * Creates a new copy of @log.\n */\nBDNVMESanitizeLog * bd_nvme_sanitize_log_copy (BDNVMESanitizeLog *log) {\n    BDNVMESanitizeLog *new_log;\n\n    if (log == NULL)\n        return NULL;\n\n    new_log = g_new0 (BDNVMESanitizeLog, 1);\n    memcpy (new_log, log, sizeof (BDNVMESanitizeLog));\n\n    return new_log;\n}\n\n\n/* can't use real __int128 due to gobject-introspection */\nstatic guint64 int128_to_guint64 (__u8 data[16])\n{\n    int i;\n    __u8 d[16];\n    guint64 result = 0;\n\n    /* endianness conversion */\n#if G_BYTE_ORDER == G_BIG_ENDIAN\n    for (i = 0; i < 16; i++)\n        d[i] = data[15 - i];\n#else\n    memcpy (d, data, sizeof (d));\n#endif\n\n    /* FIXME: would overflow */\n    /* https://github.com/linux-nvme/libnvme/issues/475 */\n    for (i = 0; i < 16; i++) {\n        result *= 256;\n        result += d[15 - i];\n    }\n    return result;\n}\n\ngint _open_dev (const gchar *device, GError **error) {\n    int fd;\n\n    fd = open (device, O_RDONLY);\n    if (fd < 0) {\n        _nvme_status_to_error (-1, FALSE, error);\n        g_prefix_error (error, \"Failed to open device '%s': \", device);\n        return -1;\n    }\n\n    return fd;\n}\n\n/* backported from nvme-cli: https://github.com/linux-nvme/nvme-cli/pull/2051 */\n#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))\n\nvoid *_nvme_alloc (size_t len, GError **error)\n{\n    size_t _len = ROUND_UP (len, 0x1000);\n    void *p;\n\n    if (posix_memalign ((void *) &p, getpagesize (), _len)) {\n        g_set_error (error, BD_NVME_ERROR, BD_NVME_ERROR_FAILED,\n                     \"Memory allocation failed: %m\");\n        return NULL;\n    }\n\n    memset (p, 0, _len);\n    return p;\n}\n\nstatic gchar *decode_nvme_rev (guint32 ver) {\n    guint16 mjr;\n    guint8 mnr, ter = 0;\n\n    mjr = ver >> 16;\n    mnr = (ver >> 8) & 0xFF;\n    /* 'ter' is only valid for >= 1.2.1 */\n    if (mjr >= 2 || mnr >= 2)\n        ter = ver & 0xFF;\n\n    if (mjr == 0 && mnr == 0)\n        return NULL;\n    if (ter == 0)\n        return g_strdup_printf (\"%u.%u\", mjr, mnr);\n    else\n        return g_strdup_printf (\"%u.%u.%u\", mjr, mnr, ter);\n}\n\nstatic gchar *_uuid_to_str (unsigned char uuid[NVME_UUID_LEN]) {\n    gchar uuid_buf[NVME_UUID_LEN_STRING] = ZERO_INIT;\n\n    if (nvme_uuid_to_string (uuid, uuid_buf) == 0)\n        return g_strdup (uuid_buf);\n    return NULL;\n}\n\nstatic gboolean _nvme_a_is_zero (const __u8 a[], int len) {\n    int i;\n\n    for (i = 0; i < len; i++)\n        if (a[i] > 0)\n            return FALSE;\n    return TRUE;\n}\n\n/**\n * bd_nvme_get_controller_info:\n * @device: a NVMe controller device (e.g. `/dev/nvme0`)\n * @error: (out) (nullable): place to store error (if any)\n *\n * Retrieves information about the NVMe controller (the Identify Controller command)\n * as specified by the @device block device path.\n *\n * Returns: (transfer full): information about given controller or %NULL in case of an error (with @error set).\n *\n * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_INFO\n */\nBDNVMEControllerInfo * bd_nvme_get_controller_info (const gchar *device, GError **error) {\n    int ret;\n    int fd;\n    struct nvme_id_ctrl *ctrl_id;\n    BDNVMEControllerInfo *info;\n\n    /* open the block device */\n    fd = _open_dev (device, error);\n    if (fd < 0)\n        return NULL;\n\n    ctrl_id = _nvme_alloc (sizeof (struct nvme_id_ctrl), error);\n    if (!ctrl_id)\n        return NULL;\n    /* send the NVME_IDENTIFY_CNS_CTRL ioctl */\n    ret = nvme_identify_ctrl (fd, ctrl_id);\n    if (ret != 0) {\n        _nvme_status_to_error (ret, FALSE, error);\n        g_prefix_error (error, \"NVMe Identify Controller command error: \");\n        close (fd);\n        free (ctrl_id);\n        return NULL;\n    }\n    close (fd);\n\n    info = g_new0 (BDNVMEControllerInfo, 1);\n    if ((ctrl_id->cmic & NVME_CTRL_CMIC_MULTI_PORT) == NVME_CTRL_CMIC_MULTI_PORT)\n        info->features |= BD_NVME_CTRL_FEAT_MULTIPORT;\n    if ((ctrl_id->cmic & NVME_CTRL_CMIC_MULTI_CTRL) == NVME_CTRL_CMIC_MULTI_CTRL)\n        info->features |= BD_NVME_CTRL_FEAT_MULTICTRL;\n    if ((ctrl_id->cmic & NVME_CTRL_CMIC_MULTI_SRIOV) == NVME_CTRL_CMIC_MULTI_SRIOV)\n        info->features |= BD_NVME_CTRL_FEAT_SRIOV;\n    if ((ctrl_id->cmic & NVME_CTRL_CMIC_MULTI_ANA_REPORTING) == NVME_CTRL_CMIC_MULTI_ANA_REPORTING)\n        info->features |= BD_NVME_CTRL_FEAT_ANA_REPORTING;\n    if ((ctrl_id->nvmsr & NVME_CTRL_NVMSR_NVMESD) == NVME_CTRL_NVMSR_NVMESD)\n        info->features |= BD_NVME_CTRL_FEAT_STORAGE_DEVICE;\n    if ((ctrl_id->nvmsr & NVME_CTRL_NVMSR_NVMEE) == NVME_CTRL_NVMSR_NVMEE)\n        info->features |= BD_NVME_CTRL_FEAT_ENCLOSURE;\n    if ((ctrl_id->mec & NVME_CTRL_MEC_PCIEME) == NVME_CTRL_MEC_PCIEME)\n        info->features |= BD_NVME_CTRL_FEAT_MGMT_PCIE;\n    if ((ctrl_id->mec & NVME_CTRL_MEC_SMBUSME) == NVME_CTRL_MEC_SMBUSME)\n        info->features |= BD_NVME_CTRL_FEAT_MGMT_SMBUS;\n    info->pci_vendor_id = GUINT16_FROM_LE (ctrl_id->vid);\n    info->pci_subsys_vendor_id = GUINT16_FROM_LE (ctrl_id->ssvid);\n    info->ctrl_id = GUINT16_FROM_LE (ctrl_id->cntlid);\n    if (!_nvme_a_is_zero (ctrl_id->fguid, sizeof (ctrl_id->fguid)))\n        info->fguid = _uuid_to_str (ctrl_id->fguid);\n    info->model_number = g_strndup (ctrl_id->mn, sizeof (ctrl_id->mn));\n    g_strstrip (info->model_number);\n    info->serial_number = g_strndup (ctrl_id->sn, sizeof (ctrl_id->sn));\n    g_strstrip (info->serial_number);\n    info->firmware_ver = g_strndup (ctrl_id->fr, sizeof (ctrl_id->fr));\n    g_strstrip (info->firmware_ver);\n    info->nvme_ver = decode_nvme_rev (GUINT32_FROM_LE (ctrl_id->ver));\n    /* TODO: vwci: VPD Write Cycle Information */\n    if ((ctrl_id->oacs & NVME_CTRL_OACS_FORMAT) == NVME_CTRL_OACS_FORMAT)\n        info->features |= BD_NVME_CTRL_FEAT_FORMAT;\n    if ((ctrl_id->oacs & NVME_CTRL_OACS_NS_MGMT) == NVME_CTRL_OACS_NS_MGMT)\n        info->features |= BD_NVME_CTRL_FEAT_NS_MGMT;\n    if ((ctrl_id->oacs & NVME_CTRL_OACS_SELF_TEST) == NVME_CTRL_OACS_SELF_TEST)\n        info->features |= BD_NVME_CTRL_FEAT_SELFTEST;\n    switch (ctrl_id->cntrltype) {\n        case NVME_CTRL_CNTRLTYPE_IO:\n            info->controller_type = BD_NVME_CTRL_TYPE_IO;\n            break;\n        case NVME_CTRL_CNTRLTYPE_DISCOVERY:\n            info->controller_type = BD_NVME_CTRL_TYPE_DISCOVERY;\n            break;\n        case NVME_CTRL_CNTRLTYPE_ADMIN:\n            info->controller_type = BD_NVME_CTRL_TYPE_ADMIN;\n            break;\n        default:\n            info->controller_type = BD_NVME_CTRL_TYPE_UNKNOWN;\n    }\n    info->hmb_pref_size = GUINT32_FROM_LE (ctrl_id->hmpre) * 4096LL;\n    info->hmb_min_size = GUINT32_FROM_LE (ctrl_id->hmmin) * 4096LL;\n    info->size_total = int128_to_guint64 (ctrl_id->tnvmcap);\n    info->size_unalloc = int128_to_guint64 (ctrl_id->unvmcap);\n    info->selftest_ext_time = GUINT16_FROM_LE (ctrl_id->edstt);\n    /* TODO: lpa: Log Page Attributes - NVME_CTRL_LPA_PERSETENT_EVENT: Persistent Event log */\n    if ((ctrl_id->dsto & NVME_CTRL_DSTO_ONE_DST) == NVME_CTRL_DSTO_ONE_DST)\n        info->features |= BD_NVME_CTRL_FEAT_SELFTEST_SINGLE;\n    if ((ctrl_id->sanicap & NVME_CTRL_SANICAP_CES) == NVME_CTRL_SANICAP_CES)\n        info->features |= BD_NVME_CTRL_FEAT_SANITIZE_CRYPTO;\n    if ((ctrl_id->sanicap & NVME_CTRL_SANICAP_BES) == NVME_CTRL_SANICAP_BES)\n        info->features |= BD_NVME_CTRL_FEAT_SANITIZE_BLOCK;\n    if ((ctrl_id->sanicap & NVME_CTRL_SANICAP_OWS) == NVME_CTRL_SANICAP_OWS)\n        info->features |= BD_NVME_CTRL_FEAT_SANITIZE_OVERWRITE;\n    /* struct nvme_id_ctrl.nn: If the &struct nvme_id_ctrl.mnan field is cleared to 0h,\n     * then the struct nvme_id_ctrl.nn field also indicates the maximum number of namespaces\n     * supported by the NVM subsystem.\n     */\n    info->num_namespaces = GUINT32_FROM_LE (ctrl_id->mnan) == 0 ? GUINT32_FROM_LE (ctrl_id->nn) : GUINT32_FROM_LE (ctrl_id->mnan);\n    if ((ctrl_id->fna & NVME_CTRL_FNA_FMT_ALL_NAMESPACES) == NVME_CTRL_FNA_FMT_ALL_NAMESPACES)\n        info->features |= BD_NVME_CTRL_FEAT_FORMAT_ALL_NS;\n    if ((ctrl_id->fna & NVME_CTRL_FNA_SEC_ALL_NAMESPACES) == NVME_CTRL_FNA_SEC_ALL_NAMESPACES)\n        info->features |= BD_NVME_CTRL_FEAT_SECURE_ERASE_ALL_NS;\n    if ((ctrl_id->fna & NVME_CTRL_FNA_CRYPTO_ERASE) == NVME_CTRL_FNA_CRYPTO_ERASE)\n        info->features |= BD_NVME_CTRL_FEAT_SECURE_ERASE_CRYPTO;\n    /* TODO: enum nvme_id_ctrl_oncs: NVME_CTRL_ONCS_WRITE_UNCORRECTABLE, NVME_CTRL_ONCS_WRITE_ZEROES... */\n    /* TODO: nwpc: Namespace Write Protection Capabilities */\n    info->subsysnqn = g_strndup (ctrl_id->subnqn, sizeof (ctrl_id->subnqn));\n    g_strstrip (info->subsysnqn);\n\n    free (ctrl_id);\n    return info;\n}\n\n\n/**\n * bd_nvme_get_namespace_info:\n * @device: a NVMe namespace device (e.g. `/dev/nvme0n1`)\n * @error: (out) (nullable): place to store error (if any)\n *\n * Retrieves information about the NVMe namespace (the Identify Namespace command)\n * as specified by the @device block device path.\n *\n * Returns: (transfer full): information about given namespace or %NULL in case of an error (with @error set).\n *\n * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_INFO\n */\nBDNVMENamespaceInfo *bd_nvme_get_namespace_info (const gchar *device, GError **error) {\n    int ret;\n    int ret_ctrl;\n    int ret_desc = -1;\n    int ret_ns_ind = -1;\n    int fd;\n    __u32 nsid = 0;\n    struct nvme_id_ctrl *ctrl_id;\n    struct nvme_id_ns *ns_info;\n    struct nvme_id_independent_id_ns *ns_info_ind = NULL;\n    struct nvme_ns_id_desc *descs = NULL;\n    guint8 flbas;\n    guint i;\n    guint len;\n    BDNVMENamespaceInfo *info;\n    GPtrArray *ptr_array;\n\n    /* open the block device */\n    fd = _open_dev (device, error);\n    if (fd < 0)\n        return NULL;\n\n    /* get Namespace Identifier (NSID) for the @device (NVME_IOCTL_ID) */\n    ret = nvme_get_nsid (fd, &nsid);\n    if (ret != 0) {\n        _nvme_status_to_error (ret, FALSE, error);\n        g_prefix_error (error, \"Error getting Namespace Identifier (NSID): \");\n        close (fd);\n        return NULL;\n    }\n\n    /* send the NVME_IDENTIFY_CNS_NS ioctl */\n    ns_info = _nvme_alloc (sizeof (struct nvme_id_ns), error);\n    if (!ns_info) {\n        close (fd);\n        return NULL;\n    }\n    ret = nvme_identify_ns (fd, nsid, ns_info);\n    if (ret != 0) {\n        _nvme_status_to_error (ret, FALSE, error);\n        g_prefix_error (error, \"NVMe Identify Namespace command error: \");\n        close (fd);\n        free (ns_info);\n        return NULL;\n    }\n\n    /* send the NVME_IDENTIFY_CNS_CTRL ioctl */\n    ctrl_id = _nvme_alloc (sizeof (struct nvme_id_ctrl), error);\n    if (!ctrl_id) {\n        close (fd);\n        free (ns_info);\n        return NULL;\n    }\n    ret_ctrl = nvme_identify_ctrl (fd, ctrl_id);\n\n    /* send the NVME_IDENTIFY_CNS_NS_DESC_LIST ioctl, NVMe 1.3 */\n    if (ret_ctrl == 0 && GUINT32_FROM_LE (ctrl_id->ver) >= 0x10300) {\n        descs = _nvme_alloc (NVME_IDENTIFY_DATA_SIZE, NULL);\n        if (descs != NULL)\n            ret_desc = nvme_identify_ns_descs (fd, nsid, descs);\n    }\n\n    /* send the NVME_IDENTIFY_CNS_CSI_INDEPENDENT_ID_NS ioctl, NVMe 2.0 */\n    if (ret_ctrl == 0 && GUINT32_FROM_LE (ctrl_id->ver) >= 0x20000) {\n        ns_info_ind = _nvme_alloc (sizeof (struct nvme_id_independent_id_ns), NULL);\n        if (ns_info_ind != NULL)\n            ret_ns_ind = nvme_identify_independent_identify_ns (fd, nsid, ns_info_ind);\n    }\n    close (fd);\n\n    info = g_new0 (BDNVMENamespaceInfo, 1);\n    info->nsid = nsid;\n    info->nsize = GUINT64_FROM_LE (ns_info->nsze);\n    info->ncap = GUINT64_FROM_LE (ns_info->ncap);\n    info->nuse = GUINT64_FROM_LE (ns_info->nuse);\n    if ((ns_info->nsfeat & NVME_NS_FEAT_THIN) == NVME_NS_FEAT_THIN)\n        info->features |= BD_NVME_NS_FEAT_THIN;\n    if ((ns_info->nmic & NVME_NS_NMIC_SHARED) == NVME_NS_NMIC_SHARED)\n        info->features |= BD_NVME_NS_FEAT_MULTIPATH_SHARED;\n    if ((ns_info->fpi & NVME_NS_FPI_SUPPORTED) == NVME_NS_FPI_SUPPORTED)\n        info->features |= BD_NVME_NS_FEAT_FORMAT_PROGRESS;\n    info->format_progress_remaining = ns_info->fpi & NVME_NS_FPI_REMAINING;\n    /* TODO: what the ns_info->nvmcap really stands for? */\n    info->write_protected = (ns_info->nsattr & NVME_NS_NSATTR_WRITE_PROTECTED) == NVME_NS_NSATTR_WRITE_PROTECTED;\n\n    if (ret_desc == 0) {\n        for (i = 0; i < NVME_IDENTIFY_DATA_SIZE; i += len) {\n            struct nvme_ns_id_desc *d = descs + i;\n\n            if (!d->nidl)\n                break;\n            len = d->nidl + sizeof (*d);\n\n            switch (d->nidt) {\n                case NVME_NIDT_EUI64:\n                    g_free (info->eui64);\n                    info->eui64 = g_malloc0 (d->nidl * 2 + 1);\n                    for (i = 0; i < d->nidl; i++)\n                        snprintf (info->eui64 + i * 2, 3, \"%02x\", d->nid[i]);\n                    break;\n                case NVME_NIDT_NGUID:\n                    g_free (info->nguid);\n                    info->nguid = g_malloc0 (d->nidl * 2 + 1);\n                    for (i = 0; i < d->nidl; i++)\n                        snprintf (info->nguid + i * 2, 3, \"%02x\", d->nid[i]);\n                    break;\n                case NVME_NIDT_UUID:\n                    g_free (info->uuid);\n                    info->uuid = _uuid_to_str (d->nid);\n                    break;\n                case NVME_NIDT_CSI:\n                    /* unused */\n                    break;\n            }\n        }\n    }\n\n    if (info->nguid == NULL && !_nvme_a_is_zero (ns_info->nguid, sizeof (ns_info->nguid))) {\n        info->nguid = g_malloc0 (sizeof (ns_info->nguid) * 2 + 1);\n        for (i = 0; i < sizeof (ns_info->nguid); i++)\n            snprintf (info->nguid + i * 2, 3, \"%02x\", ns_info->nguid[i]);\n    }\n    if (info->eui64 == NULL && !_nvme_a_is_zero (ns_info->eui64, sizeof (ns_info->eui64))) {\n        info->eui64 = g_malloc0 (sizeof (ns_info->eui64) * 2 + 1);\n        for (i = 0; i < sizeof (ns_info->eui64); i++)\n            snprintf (info->eui64 + i * 2, 3, \"%02x\", ns_info->eui64[i]);\n    }\n    if (ret_ns_ind == 0) {\n        if ((ns_info_ind->nsfeat & 1 << 4) == 1 << 4)\n            info->features |= BD_NVME_NS_FEAT_ROTATIONAL;\n    }\n\n    /* translate the LBA Format array */\n    ptr_array = g_ptr_array_new ();\n    nvme_id_ns_flbas_to_lbaf_inuse (ns_info->flbas, &flbas);\n    for (i = 0; i <= ns_info->nlbaf + ns_info->nulbaf; i++) {\n        BDNVMELBAFormat *lbaf = g_new0 (BDNVMELBAFormat, 1);\n        lbaf->data_size = 1 << ns_info->lbaf[i].ds;\n        lbaf->metadata_size = GUINT16_FROM_LE (ns_info->lbaf[i].ms);\n        lbaf->relative_performance = ns_info->lbaf[i].rp + 1;\n        g_ptr_array_add (ptr_array, lbaf);\n        if (i == flbas) {\n            info->current_lba_format.data_size = lbaf->data_size;\n            info->current_lba_format.metadata_size = lbaf->metadata_size;\n            info->current_lba_format.relative_performance = lbaf->relative_performance;\n        }\n    }\n    g_ptr_array_add (ptr_array, NULL);  /* trailing NULL element */\n    info->lba_formats = (BDNVMELBAFormat **) g_ptr_array_free (ptr_array, FALSE);\n\n    free (ctrl_id);\n    free (ns_info);\n    free (ns_info_ind);\n    free (descs);\n    return info;\n}\n\n\n/**\n * bd_nvme_get_smart_log:\n * @device: a NVMe controller device (e.g. `/dev/nvme0`)\n * @error: (out) (nullable): place to store error (if any)\n *\n * Retrieves drive SMART and general health information (Log Identifier `02h`).\n * The information provided is over the life of the controller and is retained across power cycles.\n *\n * Returns: (transfer full): health log data or %NULL in case of an error (with @error set).\n *\n * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_INFO\n */\nBDNVMESmartLog * bd_nvme_get_smart_log (const gchar *device, GError **error) {\n    int ret;\n    int ret_identify;\n    int fd;\n    struct nvme_id_ctrl *ctrl_id;\n    struct nvme_smart_log *smart_log;\n    BDNVMESmartLog *log;\n    guint i;\n\n    /* open the block device */\n    fd = _open_dev (device, error);\n    if (fd < 0)\n        return NULL;\n\n    /* send the NVME_IDENTIFY_CNS_CTRL ioctl */\n    ctrl_id = _nvme_alloc (sizeof (struct nvme_id_ctrl), error);\n    if (!ctrl_id) {\n        close (fd);\n        return NULL;\n    }\n    ret_identify = nvme_identify_ctrl (fd, ctrl_id);\n    if (ret_identify != 0) {\n        _nvme_status_to_error (ret_identify, FALSE, error);\n        g_prefix_error (error, \"NVMe Identify Controller command error: \");\n        close (fd);\n        free (ctrl_id);\n        return NULL;\n    }\n\n    /* send the NVME_LOG_LID_SMART ioctl */\n    smart_log = _nvme_alloc (sizeof (struct nvme_smart_log), error);\n    if (!smart_log) {\n        close (fd);\n        free (ctrl_id);\n        return NULL;\n    }\n    ret = nvme_get_log_smart (fd, NVME_NSID_ALL, FALSE /* rae */, smart_log);\n    if (ret != 0) {\n        _nvme_status_to_error (ret, FALSE, error);\n        g_prefix_error (error, \"NVMe Get Log Page - SMART / Health Information Log command error: \");\n        close (fd);\n        free (ctrl_id);\n        free (smart_log);\n        return NULL;\n    }\n    close (fd);\n\n    log = g_new0 (BDNVMESmartLog, 1);\n    if ((smart_log->critical_warning & NVME_SMART_CRIT_SPARE) == NVME_SMART_CRIT_SPARE)\n        log->critical_warning |= BD_NVME_SMART_CRITICAL_WARNING_SPARE;\n    if ((smart_log->critical_warning & NVME_SMART_CRIT_TEMPERATURE) == NVME_SMART_CRIT_TEMPERATURE)\n        log->critical_warning |= BD_NVME_SMART_CRITICAL_WARNING_TEMPERATURE;\n    if ((smart_log->critical_warning & NVME_SMART_CRIT_DEGRADED) == NVME_SMART_CRIT_DEGRADED)\n        log->critical_warning |= BD_NVME_SMART_CRITICAL_WARNING_DEGRADED;\n    if ((smart_log->critical_warning & NVME_SMART_CRIT_MEDIA) == NVME_SMART_CRIT_MEDIA)\n        log->critical_warning |= BD_NVME_SMART_CRITICAL_WARNING_READONLY;\n    if ((smart_log->critical_warning & NVME_SMART_CRIT_VOLATILE_MEMORY) == NVME_SMART_CRIT_VOLATILE_MEMORY)\n        log->critical_warning |= BD_NVME_SMART_CRITICAL_WARNING_VOLATILE_MEM;\n    if ((smart_log->critical_warning & NVME_SMART_CRIT_PMR_RO) == NVME_SMART_CRIT_PMR_RO)\n        log->critical_warning |= BD_NVME_SMART_CRITICAL_WARNING_PMR_READONLY;\n    log->avail_spare = smart_log->avail_spare;\n    log->spare_thresh = smart_log->spare_thresh;\n    log->percent_used = smart_log->percent_used;\n    log->total_data_read = int128_to_guint64 (smart_log->data_units_read) * 1000 * 512;\n    log->total_data_written = int128_to_guint64 (smart_log->data_units_written) * 1000 * 512;\n    log->ctrl_busy_time = int128_to_guint64 (smart_log->ctrl_busy_time);\n    log->power_cycles = int128_to_guint64 (smart_log->power_cycles);\n    log->power_on_hours = int128_to_guint64 (smart_log->power_on_hours);\n    log->unsafe_shutdowns = int128_to_guint64 (smart_log->unsafe_shutdowns);\n    log->media_errors = int128_to_guint64 (smart_log->media_errors);\n    log->num_err_log_entries = int128_to_guint64 (smart_log->num_err_log_entries);\n\n    log->temperature = (smart_log->temperature[1] << 8) | smart_log->temperature[0];\n    for (i = 0; i < G_N_ELEMENTS (smart_log->temp_sensor); i++)\n        log->temp_sensors[i] = GUINT16_FROM_LE (smart_log->temp_sensor[i]);\n    log->warning_temp_time = GUINT32_FROM_LE (smart_log->warning_temp_time);\n    log->critical_temp_time = GUINT32_FROM_LE (smart_log->critical_comp_time);\n\n    if (ret_identify == 0) {\n        log->wctemp = GUINT16_FROM_LE (ctrl_id->wctemp);\n        log->cctemp = GUINT16_FROM_LE (ctrl_id->cctemp);\n    }\n\n    /* FIXME: intentionally not providing Host Controlled Thermal Management attributes\n     *        at the moment (an optional NVMe feature), along with intentionally not providing\n     *        Power State attributes. Subject to re-evaluation in the future.\n     */\n\n    free (ctrl_id);\n    free (smart_log);\n    return log;\n}\n\n\n/**\n * bd_nvme_get_error_log_entries:\n * @device: a NVMe controller device (e.g. `/dev/nvme0`)\n * @error: (out) (nullable): place to store error (if any)\n *\n * Retrieves Error Information Log (Log Identifier `01h`) entries, used to describe\n * extended error information for a command that completed with error or to report\n * an error that is not specific to a particular command. This log is global to the\n * controller. The ordering of the entries is based on the time when the error\n * occurred, with the most recent error being returned as the first log entry.\n * As the number of entries is typically limited by the drive implementation, only\n * most recent entries are provided.\n *\n * Returns: (transfer full) (array zero-terminated=1): null-terminated list\n *          of error entries or %NULL in case of an error (with @error set).\n *\n * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_INFO\n */\nBDNVMEErrorLogEntry ** bd_nvme_get_error_log_entries (const gchar *device, GError **error) {\n    int ret;\n    int fd;\n    guint elpe;\n    struct nvme_id_ctrl *ctrl_id;\n    struct nvme_error_log_page *err_log;\n    GPtrArray *ptr_array;\n    guint i;\n\n    /* open the block device */\n    fd = _open_dev (device, error);\n    if (fd < 0)\n        return NULL;\n\n    /* find out the maximum number of error log entries as reported by the controller */\n    ctrl_id = _nvme_alloc (sizeof (struct nvme_id_ctrl), error);\n    if (!ctrl_id) {\n        close (fd);\n        return NULL;\n    }\n    ret = nvme_identify_ctrl (fd, ctrl_id);\n    if (ret != 0) {\n        _nvme_status_to_error (ret, FALSE, error);\n        g_prefix_error (error, \"NVMe Identify Controller command error: \");\n        close (fd);\n        free (ctrl_id);\n        return NULL;\n    }\n\n    elpe = ctrl_id->elpe + 1;\n    free (ctrl_id);\n\n    /* send the NVME_LOG_LID_ERROR ioctl */\n    err_log = _nvme_alloc (sizeof (struct nvme_error_log_page) * elpe, error);\n    if (!err_log) {\n        close (fd);\n        return NULL;\n    }\n    ret = nvme_get_log_error (fd, elpe, FALSE /* rae */, err_log);\n    if (ret != 0) {\n        _nvme_status_to_error (ret, FALSE, error);\n        g_prefix_error (error, \"NVMe Get Log Page - Error Information Log Entry command error: \");\n        close (fd);\n        free (err_log);\n        return NULL;\n    }\n    close (fd);\n\n    /* parse the log */\n    ptr_array = g_ptr_array_new ();\n    for (i = 0; i < elpe; i++) {\n        if (GUINT64_FROM_LE (err_log[i].error_count) > 0) {\n            BDNVMEErrorLogEntry *entry;\n\n            entry = g_new0 (BDNVMEErrorLogEntry, 1);\n            entry->error_count = GUINT64_FROM_LE (err_log[i].error_count);\n            entry->command_id = err_log[i].cmdid;\n            entry->command_specific = GUINT64_FROM_LE (err_log[i].cs);\n            entry->command_status = GUINT16_FROM_LE (err_log[i].status_field) >> 1;\n            _nvme_status_to_error (GUINT16_FROM_LE (err_log[i].status_field) >> 1, FALSE, &entry->command_error);\n            entry->lba = GUINT64_FROM_LE (err_log[i].lba);\n            entry->nsid = err_log[i].nsid;\n            entry->transport_type = err_log[i].trtype;\n            /* not providing Transport Type Specific Information here on purpose */\n\n            g_ptr_array_add (ptr_array, entry);\n        }\n    }\n    g_ptr_array_add (ptr_array, NULL);  /* trailing NULL element */\n    free (err_log);\n\n    return (BDNVMEErrorLogEntry **) g_ptr_array_free (ptr_array, FALSE);\n}\n\n\n/**\n * bd_nvme_get_self_test_log:\n * @device: a NVMe controller device (e.g. `/dev/nvme0`)\n * @error: (out) (nullable): place to store error (if any)\n *\n * Retrieves drive self-test log (Log Identifier `06h`). Provides the status of a self-test operation\n * in progress and the percentage complete of that operation, along with the results of the last\n * 20 device self-test operations.\n *\n * Returns: (transfer full): self-test log data or %NULL in case of an error (with @error set).\n *\n * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_INFO\n */\nBDNVMESelfTestLog * bd_nvme_get_self_test_log (const gchar *device, GError **error) {\n    int ret;\n    int fd;\n    struct nvme_self_test_log *self_test_log;\n    BDNVMESelfTestLog *log;\n    GPtrArray *ptr_array;\n    guint i;\n\n    /* open the block device */\n    fd = _open_dev (device, error);\n    if (fd < 0)\n        return NULL;\n\n    /* send the NVME_LOG_LID_DEVICE_SELF_TEST ioctl */\n    self_test_log = _nvme_alloc (sizeof (struct nvme_self_test_log), error);\n    if (!self_test_log) {\n        close (fd);\n        return NULL;\n    }\n    ret = nvme_get_log_device_self_test (fd, self_test_log);\n    if (ret != 0) {\n        _nvme_status_to_error (ret, FALSE, error);\n        g_prefix_error (error, \"NVMe Get Log Page - Device Self-test Log command error: \");\n        close (fd);\n        free (self_test_log);\n        return NULL;\n    }\n    close (fd);\n\n    log = g_new0 (BDNVMESelfTestLog, 1);\n    switch (self_test_log->current_operation & NVME_ST_CURR_OP_MASK) {\n        case NVME_ST_CURR_OP_NOT_RUNNING:\n            log->current_operation = BD_NVME_SELF_TEST_ACTION_NOT_RUNNING;\n            break;\n        case NVME_ST_CURR_OP_SHORT:\n            log->current_operation = BD_NVME_SELF_TEST_ACTION_SHORT;\n            break;\n        case NVME_ST_CURR_OP_EXTENDED:\n            log->current_operation = BD_NVME_SELF_TEST_ACTION_EXTENDED;\n            break;\n        case NVME_ST_CURR_OP_VS:\n        case NVME_ST_CURR_OP_RESERVED:\n        default:\n            log->current_operation = BD_NVME_SELF_TEST_ACTION_VENDOR_SPECIFIC;\n    }\n    if ((self_test_log->current_operation & NVME_ST_CURR_OP_MASK) > 0)\n        log->current_operation_completion = self_test_log->completion & NVME_ST_CURR_OP_CMPL_MASK;\n\n    ptr_array = g_ptr_array_new ();\n    for (i = 0; i < NVME_LOG_ST_MAX_RESULTS; i++) {\n        BDNVMESelfTestLogEntry *entry;\n        guint8 dsts;\n        guint8 code;\n\n        dsts = self_test_log->result[i].dsts & NVME_ST_RESULT_MASK;\n        code = self_test_log->result[i].dsts >> NVME_ST_CODE_SHIFT;\n        if (dsts == NVME_ST_RESULT_NOT_USED)\n            continue;\n\n        entry = g_new0 (BDNVMESelfTestLogEntry, 1);\n        switch (dsts) {\n            case NVME_ST_RESULT_NO_ERR:\n                entry->result = BD_NVME_SELF_TEST_RESULT_NO_ERROR;\n                break;\n            case NVME_ST_RESULT_ABORTED:\n                entry->result = BD_NVME_SELF_TEST_RESULT_ABORTED;\n                break;\n            case NVME_ST_RESULT_CLR:\n                entry->result = BD_NVME_SELF_TEST_RESULT_CTRL_RESET;\n                break;\n            case NVME_ST_RESULT_NS_REMOVED:\n                entry->result = BD_NVME_SELF_TEST_RESULT_NS_REMOVED;\n                break;\n            case NVME_ST_RESULT_ABORTED_FORMAT:\n                entry->result = BD_NVME_SELF_TEST_RESULT_ABORTED_FORMAT;\n                break;\n            case NVME_ST_RESULT_FATAL_ERR:\n                entry->result = BD_NVME_SELF_TEST_RESULT_FATAL_ERROR;\n                break;\n            case NVME_ST_RESULT_UNKNOWN_SEG_FAIL:\n                entry->result = BD_NVME_SELF_TEST_RESULT_UNKNOWN_SEG_FAIL;\n                break;\n            case NVME_ST_RESULT_KNOWN_SEG_FAIL:\n                entry->result = BD_NVME_SELF_TEST_RESULT_KNOWN_SEG_FAIL;\n                break;\n            case NVME_ST_RESULT_ABORTED_UNKNOWN:\n                entry->result = BD_NVME_SELF_TEST_RESULT_ABORTED_UNKNOWN;\n                break;\n            case NVME_ST_RESULT_ABORTED_SANITIZE:\n                entry->result = BD_NVME_SELF_TEST_RESULT_ABORTED_SANITIZE;\n                break;\n            default:\n                bd_utils_log_format (BD_UTILS_LOG_WARNING, \"Unhandled self-test log entry result code: %d\", dsts);\n                g_free (entry);\n                continue;\n        }\n        switch (code) {\n            case NVME_ST_CODE_SHORT:\n                entry->action = BD_NVME_SELF_TEST_ACTION_SHORT;\n                break;\n            case NVME_ST_CODE_EXTENDED:\n                entry->action = BD_NVME_SELF_TEST_ACTION_EXTENDED;\n                break;\n            case NVME_ST_CODE_VS:\n            case NVME_ST_CODE_RESERVED:\n                entry->action = BD_NVME_SELF_TEST_ACTION_VENDOR_SPECIFIC;\n                break;\n            default:\n                bd_utils_log_format (BD_UTILS_LOG_WARNING, \"Unhandled self-test log entry action code: %d\", code);\n                entry->action = BD_NVME_SELF_TEST_ACTION_VENDOR_SPECIFIC;\n        }\n        entry->segment = self_test_log->result[i].seg;\n        entry->power_on_hours = GUINT64_FROM_LE (self_test_log->result[i].poh);\n        if (self_test_log->result[i].vdi & NVME_ST_VALID_DIAG_INFO_NSID)\n            entry->nsid = GUINT32_FROM_LE (self_test_log->result[i].nsid);\n        if (self_test_log->result[i].vdi & NVME_ST_VALID_DIAG_INFO_FLBA)\n            entry->failing_lba = GUINT64_FROM_LE (self_test_log->result[i].flba);\n        if ((self_test_log->result[i].vdi & NVME_ST_VALID_DIAG_INFO_SC) &&\n            (self_test_log->result[i].vdi & NVME_ST_VALID_DIAG_INFO_SCT))\n            _nvme_status_to_error ((self_test_log->result[i].sct & 7) << 8 | self_test_log->result[i].sc,\n                                   FALSE, &entry->status_code_error);\n\n        g_ptr_array_add (ptr_array, entry);\n    }\n    g_ptr_array_add (ptr_array, NULL);\n    log->entries = (BDNVMESelfTestLogEntry **) g_ptr_array_free (ptr_array, FALSE);\n    free (self_test_log);\n\n    return log;\n}\n\n\n/**\n * bd_nvme_get_sanitize_log:\n * @device: a NVMe controller device (e.g. `/dev/nvme0`)\n * @error: (out) (nullable): place to store error (if any)\n *\n * Retrieves the drive sanitize status log (Log Identifier `81h`) that includes information\n * about the most recent sanitize operation and the sanitize operation time estimates.\n *\n * As advised in the NVMe specification whitepaper the host should limit polling\n * to retrieve progress of a running sanitize operations (e.g. to at most once every\n * several minutes) to avoid interfering with the progress of the sanitize operation itself.\n *\n * Returns: (transfer full): sanitize log data or %NULL in case of an error (with @error set).\n *\n * Tech category: %BD_NVME_TECH_NVME-%BD_NVME_TECH_MODE_INFO\n */\nBDNVMESanitizeLog * bd_nvme_get_sanitize_log (const gchar *device, GError **error) {\n    int ret;\n    int fd;\n    struct nvme_sanitize_log_page *sanitize_log;\n    BDNVMESanitizeLog *log;\n    __u16 sstat;\n\n    /* open the block device */\n    fd = _open_dev (device, error);\n    if (fd < 0)\n        return NULL;\n\n    /* send the NVME_LOG_LID_SANITIZE ioctl */\n    sanitize_log = _nvme_alloc (sizeof (struct nvme_sanitize_log_page), error);\n    if (!sanitize_log) {\n        close (fd);\n        return NULL;\n    }\n    ret = nvme_get_log_sanitize (fd, FALSE /* rae */, sanitize_log);\n    if (ret != 0) {\n        _nvme_status_to_error (ret, FALSE, error);\n        g_prefix_error (error, \"NVMe Get Log Page - Sanitize Status Log command error: \");\n        close (fd);\n        free (sanitize_log);\n        return NULL;\n    }\n    close (fd);\n\n    log = g_new0 (BDNVMESanitizeLog, 1);\n    log->sanitize_progress = 0;\n    sstat = GUINT16_FROM_LE (sanitize_log->sstat);\n    if ((sstat & NVME_SANITIZE_SSTAT_STATUS_MASK) == NVME_SANITIZE_SSTAT_STATUS_IN_PROGESS)\n        log->sanitize_progress = ((gdouble) GUINT16_FROM_LE (sanitize_log->sprog) * 100) / 0x10000;\n    log->global_data_erased = sstat & NVME_SANITIZE_SSTAT_GLOBAL_DATA_ERASED;\n    log->overwrite_passes = (sstat >> NVME_SANITIZE_SSTAT_COMPLETED_PASSES_SHIFT) & NVME_SANITIZE_SSTAT_COMPLETED_PASSES_MASK;\n\n    switch (sstat & NVME_SANITIZE_SSTAT_STATUS_MASK) {\n        case NVME_SANITIZE_SSTAT_STATUS_COMPLETE_SUCCESS:\n            log->sanitize_status = BD_NVME_SANITIZE_STATUS_SUCCESS;\n            break;\n        case NVME_SANITIZE_SSTAT_STATUS_IN_PROGESS:\n            log->sanitize_status = BD_NVME_SANITIZE_STATUS_IN_PROGESS;\n            break;\n        case NVME_SANITIZE_SSTAT_STATUS_COMPLETED_FAILED:\n            log->sanitize_status = BD_NVME_SANITIZE_STATUS_FAILED;\n            break;\n        case NVME_SANITIZE_SSTAT_STATUS_ND_COMPLETE_SUCCESS:\n            log->sanitize_status = BD_NVME_SANITIZE_STATUS_SUCCESS_NO_DEALLOC;\n            break;\n        case NVME_SANITIZE_SSTAT_STATUS_NEVER_SANITIZED:\n        default:\n            log->sanitize_status = BD_NVME_SANITIZE_STATUS_NEVER_SANITIZED;\n            break;\n    }\n\n    log->time_for_overwrite = (GUINT32_FROM_LE (sanitize_log->eto) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log->eto);\n    log->time_for_block_erase = (GUINT32_FROM_LE (sanitize_log->etbe) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log->etbe);\n    log->time_for_crypto_erase = (GUINT32_FROM_LE (sanitize_log->etce) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log->etce);\n    log->time_for_overwrite_nd = (GUINT32_FROM_LE (sanitize_log->etond) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log->etond);\n    log->time_for_block_erase_nd = (GUINT32_FROM_LE (sanitize_log->etbend) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log->etbend);\n    log->time_for_crypto_erase_nd = (GUINT32_FROM_LE (sanitize_log->etcend) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log->etcend);\n\n    free (sanitize_log);\n    return log;\n}\n"},
                          "roles": ["analysisTarget",
                                    "tracedFile"]}],
           "results": [{"ruleId": "-Wanalyzer-fd-leak",
                        "taxa": [{"id": "775",
                                  "toolComponent": {"name": "cwe"}}],
                        "properties": {"gcc/analyzer/saved_diagnostic/sm": "file-descriptor",
                                       "gcc/analyzer/saved_diagnostic/ploc": {"enode": 3442},
                                       "gcc/analyzer/saved_diagnostic/var": "_open_dev (device_96(D), error_97(D))",
                                       "gcc/analyzer/saved_diagnostic/sval": "CONJURED(_5 = open (device_3(D), 0);, _5)",
                                       "gcc/analyzer/saved_diagnostic/state": "fd-valid-read-only",
                                       "gcc/analyzer/saved_diagnostic/idx": 0,
                                       "gcc/analyzer/saved_diagnostic/duplicates": [{"properties": {"gcc/analyzer/saved_diagnostic/sm": "file-descriptor",
                                                                                                    "gcc/analyzer/saved_diagnostic/ploc": {"enode": 3442},
                                                                                                    "gcc/analyzer/saved_diagnostic/var": "_open_dev (device_96(D), error_97(D))",
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "CONJURED(_5 = open (device_3(D), 0);, _5)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "fd-valid-read-only",
                                                                                                    "gcc/analyzer/saved_diagnostic/idx": 1,
                                                                                                    "gcc/analyzer/pending_diagnostic/kind": "fd_leak"}}],
                                       "gcc/analyzer/pending_diagnostic/kind": "fd_leak"},
                        "level": "warning",
                        "message": {"text": "leak of file descriptor '_open_dev(device,  error)'"},
                        "locations": [{"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                 "uriBaseId": "PWD"},
                                                            "region": {"startLine": 410,
                                                                       "startColumn": 19,
                                                                       "endColumn": 20},
                                                            "contextRegion": {"startLine": 410,
                                                                              "snippet": {"text": "    size_t _len = ROUND_UP (len, 0x1000);\n"}}},
                                       "logicalLocations": [{"index": 0,
                                                             "fullyQualifiedName": "bd_nvme_get_controller_info"}]}],
                        "codeFlows": [{"threadFlows": [{"id": "main",
                                                        "locations": [{"properties": {"gcc/analyzer/checker_event/emission_id": "(1)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 470,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 51},
                                                                                                         "contextRegion": {"startLine": 470,
                                                                                                                           "snippet": {"text": "BDNVMEControllerInfo * bd_nvme_get_controller_info (const gchar *device, GError **error) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "bd_nvme_get_controller_info"}],
                                                                                    "message": {"text": "entry to 'bd_nvme_get_controller_info'"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 1},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(2)",
                                                                                      "gcc/analyzer/checker_event/kind": "call",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 881,
                                                                                                                                 "dst_id": 882}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 477,
                                                                                                                    "startColumn": 10,
                                                                                                                    "endColumn": 35},
                                                                                                         "contextRegion": {"startLine": 477,
                                                                                                                           "snippet": {"text": "    fd = _open_dev (device, error);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "bd_nvme_get_controller_info"}],
                                                                                    "message": {"text": "calling '_open_dev' from 'bd_nvme_get_controller_info'"}},
                                                                       "kinds": ["call",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 2},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(3)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 392,
                                                                                                                    "startColumn": 6,
                                                                                                                    "endColumn": 15},
                                                                                                         "contextRegion": {"startLine": 392,
                                                                                                                           "snippet": {"text": "gint _open_dev (const gchar *device, GError **error) {\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "_open_dev"}],
                                                                                    "message": {"text": "entry to '_open_dev'"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 3},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(4)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 395,
                                                                                                                    "startColumn": 10,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 395,
                                                                                                                           "snippet": {"text": "    fd = open (device, O_RDONLY);\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "_open_dev"}],
                                                                                    "message": {"text": "opened here"}},
                                                                       "kinds": ["acquire",
                                                                                 "resource"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 4},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(5)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 396,
                                                                                                                    "startColumn": 8,
                                                                                                                    "endColumn": 9},
                                                                                                         "contextRegion": {"startLine": 396,
                                                                                                                           "snippet": {"text": "    if (fd < 0) {\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "_open_dev"}],
                                                                                    "message": {"text": "assuming 'open(device, 0)' is a valid file descriptor (>= 0)"}},
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 5},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(6)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 1216,
                                                                                                                                 "dst_id": 1217}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 396,
                                                                                                                    "startColumn": 8,
                                                                                                                    "endColumn": 9},
                                                                                                         "contextRegion": {"startLine": 396,
                                                                                                                           "snippet": {"text": "    if (fd < 0) {\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "_open_dev"}],
                                                                                    "message": {"text": "following 'false' branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 6},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(7)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 1216,
                                                                                                                                 "dst_id": 1217}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 396,
                                                                                                                    "startColumn": 8,
                                                                                                                    "endColumn": 9},
                                                                                                         "contextRegion": {"startLine": 396,
                                                                                                                           "snippet": {"text": "    if (fd < 0) {\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "_open_dev"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 7},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(8)",
                                                                                      "gcc/analyzer/checker_event/kind": "return"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 477,
                                                                                                                    "startColumn": 10,
                                                                                                                    "endColumn": 35},
                                                                                                         "contextRegion": {"startLine": 477,
                                                                                                                           "snippet": {"text": "    fd = _open_dev (device, error);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "bd_nvme_get_controller_info"}],
                                                                                    "message": {"text": "returning to 'bd_nvme_get_controller_info' from '_open_dev'"}},
                                                                       "kinds": ["return",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 8},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(9)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 882,
                                                                                                                                 "dst_id": 884}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 478,
                                                                                                                    "startColumn": 8,
                                                                                                                    "endColumn": 9},
                                                                                                         "contextRegion": {"startLine": 478,
                                                                                                                           "snippet": {"text": "    if (fd < 0)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "bd_nvme_get_controller_info"}],
                                                                                    "message": {"text": "following 'false' branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 9},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(10)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 882,
                                                                                                                                 "dst_id": 884}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 481,
                                                                                                                    "startColumn": 15,
                                                                                                                    "endColumn": 64},
                                                                                                         "contextRegion": {"startLine": 481,
                                                                                                                           "snippet": {"text": "    ctrl_id = _nvme_alloc (sizeof (struct nvme_id_ctrl), error);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "bd_nvme_get_controller_info"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 10},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(11)",
                                                                                      "gcc/analyzer/checker_event/kind": "call",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 884,
                                                                                                                                 "dst_id": 885}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 481,
                                                                                                                    "startColumn": 15,
                                                                                                                    "endColumn": 64},
                                                                                                         "contextRegion": {"startLine": 481,
                                                                                                                           "snippet": {"text": "    ctrl_id = _nvme_alloc (sizeof (struct nvme_id_ctrl), error);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "bd_nvme_get_controller_info"}],
                                                                                    "message": {"text": "calling '_nvme_alloc' from 'bd_nvme_get_controller_info'"}},
                                                                       "kinds": ["call",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 11},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(12)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 408,
                                                                                                                    "startColumn": 7,
                                                                                                                    "endColumn": 18},
                                                                                                         "contextRegion": {"startLine": 408,
                                                                                                                           "snippet": {"text": "void *_nvme_alloc (size_t len, GError **error)\n"}}},
                                                                                    "logicalLocations": [{"index": 2,
                                                                                                          "fullyQualifiedName": "_nvme_alloc"}],
                                                                                    "message": {"text": "entry to '_nvme_alloc'"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 12},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(13)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 1203,
                                                                                                                                 "dst_id": 1204}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 413,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 59},
                                                                                                         "contextRegion": {"startLine": 413,
                                                                                                                           "snippet": {"text": "    if (posix_memalign ((void *) &p, getpagesize (), _len)) {\n"}}},
                                                                                    "logicalLocations": [{"index": 2,
                                                                                                          "fullyQualifiedName": "_nvme_alloc"}],
                                                                                    "message": {"text": "following 'false' branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 13},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(14)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 1203,
                                                                                                                                 "dst_id": 1204}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 413,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 59},
                                                                                                         "contextRegion": {"startLine": 413,
                                                                                                                           "snippet": {"text": "    if (posix_memalign ((void *) &p, getpagesize (), _len)) {\n"}}},
                                                                                    "logicalLocations": [{"index": 2,
                                                                                                          "fullyQualifiedName": "_nvme_alloc"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 14},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(15)",
                                                                                      "gcc/analyzer/checker_event/kind": "return"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 481,
                                                                                                                    "startColumn": 15,
                                                                                                                    "endColumn": 64},
                                                                                                         "contextRegion": {"startLine": 481,
                                                                                                                           "snippet": {"text": "    ctrl_id = _nvme_alloc (sizeof (struct nvme_id_ctrl), error);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "bd_nvme_get_controller_info"}],
                                                                                    "message": {"text": "returning to 'bd_nvme_get_controller_info' from '_nvme_alloc'"}},
                                                                       "kinds": ["return",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 15},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(16)",
                                                                                      "gcc/analyzer/checker_event/kind": "warning",
                                                                                      "gcc/analyzer/checker_event/original_fndecl": {"index": 0,
                                                                                                                                     "fullyQualifiedName": "bd_nvme_get_controller_info"}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "nvme-info.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 410,
                                                                                                                    "startColumn": 19,
                                                                                                                    "endColumn": 20},
                                                                                                         "contextRegion": {"startLine": 410,
                                                                                                                           "snippet": {"text": "    size_t _len = ROUND_UP (len, 0x1000);\n"}}},
                                                                                    "logicalLocations": [{"index": 2,
                                                                                                          "fullyQualifiedName": "_nvme_alloc"}],
                                                                                    "message": {"text": "'_open_dev(device,  error)' leaks here; was opened at [(4)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/3)"}},
                                                                       "kinds": ["danger"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 16}]}]}]}],
           "logicalLocations": [{"name": "bd_nvme_get_controller_info",
                                 "fullyQualifiedName": "bd_nvme_get_controller_info",
                                 "decoratedName": "bd_nvme_get_controller_info",
                                 "kind": "function",
                                 "index": 0},
                                {"name": "_open_dev",
                                 "fullyQualifiedName": "_open_dev",
                                 "decoratedName": "_open_dev",
                                 "kind": "function",
                                 "index": 1},
                                {"name": "_nvme_alloc",
                                 "fullyQualifiedName": "_nvme_alloc",
                                 "decoratedName": "_nvme_alloc",
                                 "kind": "function",
                                 "index": 2}]}]}
