On Tue, 7 Jul 2020 16:45:07 -0700, Ranjit Menon wrote:
> On 7/7/2020 1:22 PM, Dmitry Kozlyuk wrote:
> > AdjustTokenPrivileges() succeeds even if no requested privileges have
> > been granted; this behavior is documented. Check last error code in
> > addition to return value to detect such case.
> >
> > Signed-off-by: Dmitry Kozlyuk <dmitry.kozl...@gmail.com>
> > ---
> >   lib/librte_eal/windows/eal_hugepages.c | 4 ++++
> >   1 file changed, 4 insertions(+)
> >
> > diff --git a/lib/librte_eal/windows/eal_hugepages.c 
> > b/lib/librte_eal/windows/eal_hugepages.c
> > index 5779cd325..07a5467d0 100644
> > --- a/lib/librte_eal/windows/eal_hugepages.c
> > +++ b/lib/librte_eal/windows/eal_hugepages.c
> > @@ -41,6 +41,10 @@ hugepage_claim_privilege(void)
> >             goto exit;
> >     }
> >   
> > +   /* AdjustTokenPrivileges() may succeed with ERROR_NOT_ALL_ASSIGNED. */
> > +   if (GetLastError() != ERROR_SUCCESS)
> > +           goto exit;
> > +
> >     ret = 0;
> >   
> >   exit:  
> 
> Wouldn't this be better if we could print a message here after 
> explicitly checking for the ERROR_NOT_ALL_ASSIGNED return value?
> 
> Otherwise, the caller simply gets a -1 return value for a failure with 
> no message.

Message is printed at ERR level by the caller. There's no context to add here.

-- 
Dmitry Kozlyuk

Reply via email to