readeeprom: Allow FRU ID 0 to be selected

We incorrectly checked that FRU ID != 0, which is the default FRU ID.
Actually, the IPMI spec specifies FRU ID 0xff as reserved, so the check
was changed to prevent that ID from being used instead.

Split out fruid parsing code to its own function to cover various edge
and failure cases.

Tested:
Ran 'phosphor-read-eeprom --eeprom fru.bin --fruid=0' and checked that
values are reported to inventory as expected.
Ran with '--fruid=ff' ('invalid' FRU ID): rejected
Ran with '--fruid=xx' (non-HEX FRU ID): rejected
Ran with '--fruid=100' (out-of-range FRU ID): rejected
Ran with '--fruid="0 0"' (invalid number): rejected
Ran with '--fruid=10.0' (non-integer): rejected
Ran with '--fruid=0x12' (valid HEX FRU ID): accepted
Ran with '--fruid=fe' (valid HEX FRU ID): accepted

Change-Id: Ic1fb79cefc6931f21d0b5cb4363ad5fd44f47c92
Signed-off-by: Oskar Senft <osk@google.com>
1 file changed
tree: c58464df696dc52b2862e54e433a820213b613e2
  1. scripts/
  2. .clang-format
  3. .gitignore
  4. argument.cpp
  5. argument.hpp
  6. bootstrap.sh
  7. configure.ac
  8. fru_area.cpp
  9. fru_area.hpp
  10. frup.cpp
  11. frup.hpp
  12. LICENSE
  13. MAINTAINERS
  14. Makefile.am
  15. readeeprom.cpp
  16. README.md
  17. strgfnhandler.cpp
  18. types.hpp
  19. writefrudata.cpp
  20. writefrudata.hpp
README.md

To Build

To build this package, do the following steps:

    1. ./bootstrap.sh
    2. ./configure ${CONFIGURE_FLAGS}
    3. make

To full clean the repository again run `./bootstrap.sh clean`.