On Mon, Feb 12, 2018 at 09:36:57AM -0600, Brijesh Singh wrote: [...] > +#define SEV_FW_MAX_ERROR 0x17 > + > +static const char *const sev_fw_errlist[] = { This requires anybody reading the code to manually count the number of items on the array to be sure fw_error_to_str() is safe. What about: #define SEV_FW_MAX_ERROR ARRAY_SIZE(sev_fw_errlist) > + "", > + "Platform state is invalid", > + "Guest state is invalid", > + "Platform configuration is invalid", > + "Buffer too small", > + "Platform is already owned", > + "Certificate is invalid", > + "Policy is not allowed", > + "Guest is not active", > + "Invalid address", > + "Bad signature", > + "Bad measurement", > + "Asid is already owned", > + "Invalid ASID", > + "WBINVD is required", > + "DF_FLUSH is required", > + "Guest handle is invalid", > + "Invalid command", > + "Guest is active", > + "Hardware error", > + "Hardware unsafe", > + "Feature not supported", > + "Invalid parameter" > +}; [...] > +fw_error_to_str(int code) > +{ > + if (code >= SEV_FW_MAX_ERROR) { > + return "unknown error"; > + } > + > + return sev_fw_errlist[code]; > +} > + -- Eduardo