Beberapa waktu lalu, muncul pesan error ketika saya melakukan kompilasi flashrom. Berikut ini adalah pesan error yang muncul:

libflashrom.c: In function 'flashrom_supported_boards':
libflashrom.c:191:32: error: implicit conversion from 'const enum test_state' to 'enum flashrom_test_state' [-Werror=enum-conversion]
  191 |    supported_boards[i].working = binfo[i].working;
      |                                ^
libflashrom.c: In function 'flashrom_supported_chipsets':
libflashrom.c:229:33: error: implicit conversion from 'const enum test_state' to 'enum flashrom_test_state' [-Werror=enum-conversion]
  229 |    supported_chipsets[i].status = chipset[i].status;

Seperti yang dapat dilihat di atas, pesan error tersebut muncul karena terdapat implicit conversion. Dan cara untuk mengatasinya adalah dengan menambahkan konversi pada kedua baris pada 2 fungsi tersebut. Berikut ini adalah fungsi yang dimaksud:

struct flashrom_board_info *flashrom_supported_boards(void)
{
#if CONFIG_INTERNAL == 1
    int boards_known_size = 0;
    int i = 0;
    const struct board_info *binfo = boards_known;

    while ((binfo++)->vendor)
        ++boards_known_size;
    binfo = boards_known;
    /* add place for {0} */
    ++boards_known_size;

    struct flashrom_board_info *supported_boards =
        malloc(boards_known_size * sizeof(struct flashrom_board_info));

    if (supported_boards != NULL) {
        for (; i < boards_known_size; ++i) {
            supported_boards[i].vendor = binfo[i].vendor;
            supported_boards[i].name = binfo[i].name;
            supported_boards[i].working = (enum flashrom_test_state) binfo[i].working; // UBAH_DI_SINI
        }
    } else {
        msg_gerr("Memory allocation error!\n");
    }

    return supported_boards;
#else
    return NULL;
#endif
}

/**
 * @brief Returns list of supported chipsets
 * @return List of supported chipsets, or NULL if an error occurred
 */
struct flashrom_chipset_info *flashrom_supported_chipsets(void)
{
#if CONFIG_INTERNAL == 1
    int chipset_enables_size = 0;
    int i = 0;
    const struct penable *chipset = chipset_enables;

    while ((chipset++)->vendor_name)
        ++chipset_enables_size;
    chipset = chipset_enables;
    /* add place for {0}*/
    ++chipset_enables_size;

    struct flashrom_chipset_info *supported_chipsets =
        malloc(chipset_enables_size * sizeof(*supported_chipsets));

    if (supported_chipsets != NULL) {
        for (; i < chipset_enables_size; ++i) {
            supported_chipsets[i].vendor = chipset[i].vendor_name;
            supported_chipsets[i].chipset = chipset[i].device_name;
            supported_chipsets[i].vendor_id = chipset[i].vendor_id;
            supported_chipsets[i].chipset_id = chipset[i].device_id;
            supported_chipsets[i].status = (enum flashrom_test_state) chipset[i].status; // UBAH_DI_SINI
      }
    } else {
        msg_gerr("Memory allocation error!\n");
    }

    return supported_chipsets;
#else
    return NULL;
#endif
}

Untuk memudahkan proses patching, kita dapat membuat file diff seperti ini:

diff -ru flashrom-old/libflashrom.c flashrom/libflashrom.c
--- flashrom-old/libflashrom.c  2020-05-11 17:34:52.997109302 +0800
+++ flashrom/libflashrom.c      2020-05-11 17:23:02.835553043 +0800
@@ -188,7 +188,7 @@
                for (; i < boards_known_size; ++i) {
                        supported_boards[i].vendor = binfo[i].vendor;
                        supported_boards[i].name = binfo[i].name;
-                       supported_boards[i].working = binfo[i].working;
+                       supported_boards[i].working = (enum flashrom_test_state) binfo[i].working;
                }
        } else {
                msg_gerr("Memory allocation error!\n");
@@ -226,7 +226,7 @@
                        supported_chipsets[i].chipset = chipset[i].device_name;
                        supported_chipsets[i].vendor_id = chipset[i].vendor_id;
                        supported_chipsets[i].chipset_id = chipset[i].device_id;
-                       supported_chipsets[i].status = chipset[i].status;
+                       supported_chipsets[i].status = (enum flashrom_test_state) chipset[i].status;
          }
        } else {
                msg_gerr("Memory allocation error!\n");

Perhatikan bahwa file diff tersebut menggunakan tabulasi dan bukan spasi, karena hal tersebut dapat menyebabkan error ketika melakukan patching. Selanjutnya, untuk melakukan patching, cukup simpan file tersebut pada direktori dimana flashrom berada dan jalankan seperti ini sebelum melakukan kompilasi dan instalasi:

% git clone https://github.com/flashrom/flashrom.git
% patch -p0 < flashrom-fix-enum.diff
% cd flashrom
% make -j4
% sudo make install

Sekian jurnal singkat kali ini, semoga bermanfaat. Terima kasih kepada Allah SWT, dan Anda yang telah membaca jurnal ini.

Mantap om! :+1