Re: [lng-odp] [PATCH] linux-gen: set errno = 0 before mmap

2017-04-13 Thread Oriol Arcas
Just following the recommendations: "Set errno to zero before calling a library function known to set errno, and check errno only after the function returns a value indicating failure" I think in general it is not a good idea to set errno after a library call. In this case it could be done, but

Re: [lng-odp] [PATCH] linux-gen: set errno = 0 before mmap

2017-04-13 Thread Maxim Uvarov
Why not just set errno to 0 in the success case? On 04/13/17 17:05, Oriol Arcas wrote: > Fixes bug #2921. > > During odp_shm_reserve() mmap is tried with huge pages, and if it fails, > without huge pages. The first call leaves errno set, which can confuse > the client app. > > In general, errno

[lng-odp] [PATCH] linux-gen: set errno = 0 before mmap

2017-04-13 Thread Oriol Arcas
Fixes bug #2921. During odp_shm_reserve() mmap is tried with huge pages, and if it fails, without huge pages. The first call leaves errno set, which can confuse the client app. In general, errno must be cleared before calling any library call known to set it (see SEI CERT rule ERR30-C).