[patch v2 2/2] stdio: Add more setvbuf tests

Joseph Myers josmyers@redhat.com
Mon Mar 31 21:35:58 GMT 2025


On Thu, 27 Mar 2025, DJ Delorie wrote:

> +      while (i < BUFSIZ)
> +	{
> +	  wn = write (fd, test_data+i, BUFSIZ-i);

We'd normally use spaces around binary operators '+' and '-'.

> +  writer_thread_tid = xpthread_create (NULL, writer_thread_proc,
> +				       (void *)& thread_data);
> +}
> +
> +static void
> +start_writer_thread_n (const char *fname)
> +{
> +  debug;
> +  thread_data.fd = 0;
> +  thread_data.fname = fname;
> +  writer_thread_tid = xpthread_create (NULL, writer_thread_proc,
> +				       (void *)& thread_data);

We wouldn't normally have a space after unary '&'.

> +static void
> +start_reader_thread (int fd)
> +{
> +  debug;
> +  thread_data.fd = fd;
> +  thread_data.fname = NULL;
> +  reader_thread_tid = xpthread_create (NULL, reader_thread_proc,
> +				       (void *)& thread_data);
> +}
> +
> +static void
> +start_reader_thread_n (const char *fname)
> +{
> +  debug;
> +  thread_data.fd = 0;
> +  thread_data.fname = fname;
> +  reader_thread_tid = xpthread_create (NULL, reader_thread_proc,
> +				       (void *)& thread_data);

Likewise.

> +    case test_source_pipe:
> +      {
> +	debug;
> +	TEST_COMPARE (pipe (test_pipe), 0);

It looks like this is a case where the subsequent code expects pipe to 
have succeeded, so xpipe would be better.

> +  if (test_stream_reads[s])
> +    {
> +      char buf[10];
> +      dumpfp (fp);
> +      size_t fc = fread (buf, 1, 10-1, fp);

Another case where spaces around a binary operator would seem appropriate 
(or sizeof buf - 1 if that's what's meant).

> +	  TEST_COMPARE_BLOB (buf, count-1, test_data+1, count-1);

More such cases for spaces.

> +	  TEST_COMPARE_BLOB (fp->_IO_read_base, count, test_data, count);
> +	}
> +    }
> +  else
> +    {
> +      dumpfp (fp);
> +      test_put_string (fp, test_data+1, 10-1);

Likewise.

> +  if (test_stream_reads[s])
> +    {
> +      char buf[10];
> +      dumpfp (fp);
> +      size_t fc = fread (buf, 1, 10-1, fp);

Likewise.

> +      /* We already checked for the first character being 'a'.  */
> +      if (count > 1)
> +	{
> +	  TEST_COMPARE_BLOB (buf, count-1, test_data+1, count-1);

Likewise.

> +  else
> +    {
> +      dumpfp (fp);
> +      test_put_string (fp, test_data+1, 10-1);

Likewise.

> +      for (i=0; i<=argc; i++)

Likewise.

> +  for (enum test_source_case f = 0; f < test_source_count; ++ f)
> +    for (enum test_stream_case s = 0; s < test_stream_count; ++ s)
> +      for (enum test_config_case c = 0; c < test_config_count; ++ c)

We wouldn't normally have spaces after unary '++'.

OK with the fixes indicated.

-- 
Joseph S. Myers
josmyers@redhat.com



More information about the Libc-alpha mailing list