[flashrom] [PATCH] Add dmidecode quirk workaround
Sean Nelson
audiohacked at gmail.com
Sun Aug 8 19:59:12 CEST 2010
On 08/08/2010 02:24 AM, Michael Karcher wrote:
> dmidecode emits a warning message about unsupported SMBIOS versions
> to stdout before the information asked for when using "-s". I consider
> this behaviour broken, but we still need to workaround it as e.g. Fedora
> currently distributes an dmidecode with this behaviour.
>
> Signed-off-by: Michael Karcher<flashrom at mkarcher.dialup.fu-berlin.de>
> ---
> dmi.c | 24 ++++++++++++++++--------
> 1 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/dmi.c b/dmi.c
> index cf459ec..98d595c 100644
> --- a/dmi.c
> +++ b/dmi.c
> @@ -76,15 +76,23 @@ static char *get_dmi_string(const char *string_name)
> msg_perr("DMI pipe open error\n");
> return NULL;
> }
> - if (!fgets(answerbuf, DMI_MAX_ANSWER_LEN, dmidecode_pipe)) {
> - if(ferror(dmidecode_pipe)) {
> - msg_perr("DMI pipe read error\n");
> - pclose(dmidecode_pipe);
> - return NULL;
> - } else {
> - answerbuf[0] = 0; /* Hit EOF */
> +
> + /* Kill lines starting with '#', as recent dmidecode versions
> + have the quirk to emit a "# SMBIOS implementations newer..."
> + message even on "-s", when it *should* only print the
> + requested string. */
> + do {
> + if (!fgets(answerbuf, DMI_MAX_ANSWER_LEN, dmidecode_pipe)) {
> + if(ferror(dmidecode_pipe)) {
> + msg_perr("DMI pipe read error\n");
> + pclose(dmidecode_pipe);
> + return NULL;
> + } else {
> + answerbuf[0] = 0; /* Hit EOF */
> + }
> }
> - }
> + } while(answerbuf[0] == '#');
> +
> /* Toss all output above DMI_MAX_ANSWER_LEN away to prevent
> deadlock on pclose. */
> while (!feof(dmidecode_pipe))
Upcoming Fedora 14 doesn't have this problem, but the patch doesn't hurt
either. So, this is
Acked-by: Sean Nelson <audiohacked at gmail.com>
More information about the flashrom
mailing list