Patchwork don't print dmidecode shell error

login
register
about
Submitter Stefan Tauner
Date 2011-06-27 12:44:03
Message ID <201106271243.p5RChekf006733@mail2.student.tuwien.ac.at>
Download mbox | patch
Permalink /patch/3217/
State Under Review
Headers show

Comments

Stefan Tauner - 2011-06-27 12:44:03
On Thu, 07 Apr 2011 19:16:04 +0200
Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de> wrote:

> Am Donnerstag, den 07.04.2011, 18:40 +0200 schrieb Stefan Reinauer:
> > * Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
> > > Not every OS has a unix command interpreter. This will break on
> > > DOS. Most likely fine if DOS is detected per ifdef.
> > Ok, how about this one? 
> 
> > Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
> 
> > +#if defined (__DJGPP__) || defined (_WIN32)
> That might be overly conservative, but I am fine with out. while
> command.com does not support 2>something, I am quite sure cmd.exe does.

stepan told me to commit this, but i hesitate. i want to integrate
dos/win support first.

i would drop the __DJGPP__ flag there because /dev/null is supported by
it: http://www.delorie.com/djgpp/doc/eli-m17n99.html#Unix%20devices
additionally i would use 2>NUL for win32. for xp there is official
documentation. a friend of mine also tried it on win2k so i would say
it is fairly safe to use it?
Bernd Blaauw - 2011-06-27 12:54:49
Op 27-6-2011 14:44, Stefan Tauner schreef:
> stepan told me to commit this, but i hesitate. i want to integrate
> dos/win support first.
>
> i would drop the __DJGPP__ flag there because /dev/null is supported by
> it: http://www.delorie.com/djgpp/doc/eli-m17n99.html#Unix%20devices
> additionally i would use 2>NUL for win32. for xp there is official
> documentation. a friend of mine also tried it on win2k so i would say
> it is fairly safe to use it?

It would be kind to be able to detect a missing DMIDECOD.EXE (DOS) or 
DMIDECODE.EXE (LFN platforms, likely thus only Windows/ReactOS) only 
once, instead of ending up with
6 times the line "bad command or filename" (sent to stdout only, unable 
to redirect to textfile). Searching current directory, flashrom's 
directory as well as entire path, should do, I guess.
Stefan Tauner - 2011-06-27 13:29:09
On Mon, 27 Jun 2011 14:54:49 +0200
Bernd Blaauw <bblaauw@home.nl> wrote:

> Op 27-6-2011 14:44, Stefan Tauner schreef:
> > stepan told me to commit this, but i hesitate. i want to integrate
> > dos/win support first.
> >
> > i would drop the __DJGPP__ flag there because /dev/null is supported by
> > it: http://www.delorie.com/djgpp/doc/eli-m17n99.html#Unix%20devices
> > additionally i would use 2>NUL for win32. for xp there is official
> > documentation. a friend of mine also tried it on win2k so i would say
> > it is fairly safe to use it?
> 
> It would be kind to be able to detect a missing DMIDECOD.EXE (DOS) or 
> DMIDECODE.EXE (LFN platforms, likely thus only Windows/ReactOS) only 
> once, instead of ending up with
> 6 times the line "bad command or filename" (sent to stdout only, unable 
> to redirect to textfile).
does it with the previously attached patch still?

> Searching current directory, flashrom's 
> directory as well as entire path, should do, I guess.
patches are welcome ;)
Bernd Blaauw - 2011-06-27 13:43:47
Op 27-6-2011 15:29, Stefan Tauner schreef:
> does it with the previously attached patch still?
Can't say, I'm a simple Windows/Dos user, thus leeching on Idwer's DOS 
compilation.
Someday I'll start with Linux and compiling, likely the day I purchase 
that Asrock E350M board for Coreboot attempting to create a 'full' 
opensource machine.
>> Searching current directory, flashrom's
>> directory as well as entire path, should do, I guess.
> patches are welcome ;)

Thanks for the offer :)

Patch

From a6e760c92186c7a6c8f7168ada0cfc7e2594f55d Mon Sep 17 00:00:00 2001
From: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Date: Mon, 27 Jun 2011 14:41:46 +0200
Subject: [PATCH] don't print dmidecode shell error

Don't print the error "sh: dmidecode: not found" if dmidecode is not there.
Uses stderr redirection to /dev/null (or NUL on win32).

Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
---
 dmi.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/dmi.c b/dmi.c
index cda6656..318d89e 100644
--- a/dmi.c
+++ b/dmi.c
@@ -75,7 +75,11 @@  static const struct {
 };
 
 #define DMI_COMMAND_LEN_MAX 260
-static const char *dmidecode_command = "dmidecode";
+#if defined (_WIN32)
+static const char *dmidecode_command = "dmidecode.exe 2>NUL";
+#else
+static const char *dmidecode_command = "dmidecode 2>/dev/null";
+#endif
 
 static char *dmistrings[ARRAY_SIZE(dmidecode_names)];
 
-- 
1.7.1