Re: [PATCH v2 2/2] selftests/nolibc: add testcase for pipe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Aug 1, 2023 14:23:22 Yuan Tan <tanyuan@xxxxxxxxxxx>:

>>> Would this be fine?
>>>
>>> static int test_pipe(void)
>>> {
>>>         const char *const msg = "hello, nolibc";
>>>         int pipefd[2];
>>>         char buf[32];
>>>         ssize_t len;
>>>
>>>         if (pipe(pipefd) == -1)
>>>                 return 1;
>>>
>>>         write(pipefd[1], msg, strlen(msg));
>>>         close(pipefd[1]);
>>>         len = read(pipefd[0], buf, sizeof(buf));
>>>         close(pipefd[0]);
>>>
>>>         if (len != strlen(msg))
>>>                 return 1;
>>>
>>>         return !!memcmp(buf, msg, len);
>>> }
>>
>> Looks good!
>>
>> The return value of write() could also be validated but given we
>> validate the return value from read() it shouldn't make a difference.
>>
>> (Also the manual manipulation of "buf" is gone that necessitated the
>> check in v1 of the series)
>>
>
> I am sorry that I didn't catch your last sentence.
>
> Did you mean this piece of code does not need any further modifications
> right?

Yes, for me this is great!
Sorry for being unclear.




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux