[PATCH ipmi-fru-parser v2] Replacing std::ifstream by access(2) for checking file existence

Patrick Williams patrick at stwcx.xyz
Wed Jun 1 07:17:45 AEST 2016


On Tue, May 31, 2016 at 01:20:14AM -0500, OpenBMC Patches wrote:
> From: vishwa <vishwanath at in.ibm.com>
> 
> ---
>  writefrudata.C | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/writefrudata.C b/writefrudata.C
> index 7ee2127..6ca1f16 100644
> --- a/writefrudata.C
> +++ b/writefrudata.C
> @@ -663,7 +663,7 @@ int ipmi_validate_fru_area(const uint8_t fruid, const char *fru_file_name,
>                           (fruid, get_fru_area_type(fru_entry), bus_type, bmc_fru);
>  
>          // Physically being present
> -        bool present = std::ifstream(fru_file_name);
> +        bool present = access(fru_file_name, F_OK) != -1;

We need to make an assessment on when to use STL interfaces vs when to
use direct syscalls in C++ programs. I don't have any problem with this
change now without any direction.

Prefer to either write this as:
    - access(..) == 0
    - access(..) >= 0


>          fru_area->set_present(present);
>  
>          // Only setup dbus path for areas defined in BMC.
> -- 
> 2.8.3
> 
> 
> _______________________________________________
> openbmc mailing list
> openbmc at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc

-- 
Patrick Williams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20160531/3096fbda/attachment-0001.sig>


More information about the openbmc mailing list