[PATCH ipmi-fru-parser] Replacing std::ifstream by access(2) for checking file existence
Samuel Mendoza-Jonas
sam at mendozajonas.com
Tue May 31 09:21:02 AEST 2016
On Mon, May 30, 2016 at 03: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..6e28341 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) ? true : false;
Hi Vishwa,
Since (access(..) != -1) returns a boolean you can simplify this to:
bool present = access(fru_file_name, F_OK) != -1;
> 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
More information about the openbmc
mailing list