On 06/10/2015 01:08 PM, Cyril Hrubis wrote:
> Hi!
>> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmansk...@oracle.com>
>> ---
>>   lib/tst_device.c |   17 ++++++-----------
>>   1 files changed, 6 insertions(+), 11 deletions(-)
>>
>> diff --git a/lib/tst_device.c b/lib/tst_device.c
>> index 3bded53..9a92fc8 100644
>> --- a/lib/tst_device.c
>> +++ b/lib/tst_device.c
>> @@ -150,30 +150,25 @@ static void attach_device(void (*cleanup_fn)(void),
>>
>>   static void detach_device(void (*cleanup_fn)(void), const char *dev)
>>   {
>> -    int dev_fd, err, i;
>> +    int dev_fd, ret, i;
>>
>>      dev_fd = SAFE_OPEN(cleanup_fn, dev, O_RDONLY);
>>
>> -    /* keep trying to clear LOOPDEV fd if EBUSY, a quick succession
>> +    /* keep trying to clear LOOPDEV until we get ENXIO, a quick succession
>>       * of attach/detach might not give udev enough time to complete */
>>      for (i = 0; i < 40; i++) {
>> -            if (ioctl(dev_fd, LOOP_CLR_FD, 0) == 0) {
>> +            ret = ioctl(dev_fd, LOOP_CLR_FD, 0);
>> +
>> +            if (ret && (errno == ENXIO)) {
>>                      close(dev_fd);
>>                      return;
>>              }
>> -            if (errno != EBUSY) {
>> -                    err = errno;
>> -                    close(dev_fd);
>> -                    tst_brkm(TBROK, cleanup_fn,
>> -                            "ioctl(%s, LOOP_CLR_FD, 0) failed: %s",
>> -                            dev, tst_strerrno(err));
>> -            }
>
> I would be a bit more verbose and would print an TINFO or TWARN message
> if we get error different from the expected EBUSY or ENXIO.

Do you mean printing of TINFO/TWARN messages right in the cycle?

                if (errno != EBUSY) {
                        err = errno;
                        tst_resm(TWARN,
                                "ioctl(%s, LOOP_CLR_FD, 0) unexpectedly failed 
with: %s",
                                dev, tst_strerrno(err));
                }


But in the worst case, we may end up with 40 messages generated.

Or do you mean saving the last errno and printing it to the final tst_brkm?


>
> Otherwise it looks fine, acked.
>

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to