[Spice-devel] [PATCH spice-gtk 23/44] fixup! usb-redir: add files for SCSI and USB MSC implementation
Frediano Ziglio
fziglio at redhat.com
Tue Jul 30 12:03:11 UTC 2019
Use constructor to initialize structure, avoid multiple calls
to cd_scsi_cmd_names_init and a variable.
---
src/cd-scsi.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/src/cd-scsi.c b/src/cd-scsi.c
index 9963762f..2a3595bb 100644
--- a/src/cd-scsi.c
+++ b/src/cd-scsi.c
@@ -112,7 +112,6 @@ struct CdScsiTarget {
CdScsiLU units[MAX_LUNS];
};
-static gboolean cmd_names_initialized = FALSE;
static const char* scsi_cmd_name[256];
/* Predefined sense codes */
@@ -371,14 +370,10 @@ static void cd_scsi_cmd_complete_good(CdScsiLU *dev, CdScsiRequest *req)
/* SCSI Target */
-static void cd_scsi_cmd_names_init(void)
+SPICE_CONSTRUCTOR_FUNC(cd_scsi_cmd_names_init)
{
uint32_t opcode;
- if (cmd_names_initialized) {
- return;
- }
-
for (opcode = 0; opcode < 256; opcode++) {
scsi_cmd_name[opcode] = "UNSUPPORTED";
}
@@ -407,8 +402,6 @@ static void cd_scsi_cmd_names_init(void)
scsi_cmd_name[START_STOP] = "START STOP UNIT";
scsi_cmd_name[MMC_GET_PERFORMANCE] = "GET PERFORMANCE";
scsi_cmd_name[MMC_MECHANISM_STATUS] = "MECHANISM STATUS";
-
- cmd_names_initialized = TRUE;
}
CdScsiTarget *cd_scsi_target_alloc(void *target_user_data, uint32_t max_luns)
@@ -428,8 +421,6 @@ CdScsiTarget *cd_scsi_target_alloc(void *target_user_data, uint32_t max_luns)
st->cancellable = g_cancellable_new();
st->max_luns = max_luns;
- cd_scsi_cmd_names_init();
-
return st;
}
--
2.20.1
More information about the Spice-devel
mailing list