public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>,
	Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Cc: Robert O'Callahan <robert@ocallahan.org>,
	"Dmitry V . Levin" <ldv@altlinux.org>
Subject: Re: [PATCH 3/6] sysvipc: Fix IPC_INFO and MSG_INFO handling [BZ #26639]
Date: Tue, 29 Sep 2020 09:37:46 -0300	[thread overview]
Message-ID: <1b71983c-db12-a6ff-692d-1ab3bd784758@linaro.org> (raw)
In-Reply-To: <87blhpyq09.fsf@oldenburg2.str.redhat.com>



On 29/09/2020 04:57, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> +static int
>> +read_proc_file (const char *file)
>> +{
>> +  FILE *f = fopen (file, "r");
>> +  if (f == NULL)
>> +    return -1;
>> +
>> +  int v;
>> +  int r = fscanf (f, "%d", & v);
>> +  TEST_VERIFY_EXIT (r == 1);
>> +
>> +  fclose (f);
>> +  return v;
>> +}
> 
> You could use xfopen and xfclose.

Indeed, I will change it.

> 
>> +/* Check if the message queue with IDX (index into the kernel's internal
>> +   array) matches the one with KEY.  The CMD is either MSG_STAT or
>> +   MSG_STAT_ANY.  */
>> +
>> +static bool
>> +check_msginfo (int idx, key_t key, int cmd)
>> +{
>> +  struct msqid_ds msginfo;
>> +  int mid = msgctl (idx, cmd, &msginfo);
>> +  /* Ignore unused array slot returned by the kernel or information from
>> +     unknown message queue.  */
>> +  if ((mid == -1 && errno == EINVAL) || mid != msqid)
>> +    return false;
>> +
>> +  if (mid == -1)
>> +    FAIL_EXIT1 ("msgctl with %s failed: %m",
>> +		cmd == MSG_STAT ? "MSG_STAT" : "MSG_STAT_ANY");
>> +
>> +  if (msginfo.msg_perm.__key != key)
>> +    FAIL_EXIT1 ("msgid_ds::msg_perm::key (%d) != %d",
>> +		(int) msginfo.msg_perm.__key, (int) key);
>> +  if (msginfo.msg_perm.mode != MSGQ_MODE)
>> +    FAIL_EXIT1 ("msgid_ds::msg_perm::mode (%o) != %o",
>> +		msginfo.msg_perm.mode, MSGQ_MODE);
>> +  if (msginfo.msg_qnum != 0)
>> +    FAIL_EXIT1 ("msgid_ds::msg_qnum (%lu) != 0",
>> +		(long unsigned) msginfo.msg_qnum);
> 
> As in the other patch, you might want to use TEST_COMPARE here.

Yes, I changed it as well from the other patch review.

> 
> Rest looks okay, I think.
> 
> Thanks,
> Florian
> 

  reply	other threads:[~2020-09-29 12:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 14:45 [PATCH 1/6] sysvipc: Fix SEM_STAT_ANY kernel argument pass [BZ #26637] Adhemerval Zanella
2020-09-28 14:45 ` [PATCH 2/6] sysvipc: Return EINVAL for invalid semctl commands Adhemerval Zanella
2020-09-28 16:33   ` Florian Weimer
2020-09-28 21:07     ` Adhemerval Zanella
2020-09-28 14:45 ` [PATCH 3/6] sysvipc: Fix IPC_INFO and MSG_INFO handling [BZ #26639] Adhemerval Zanella
2020-09-28 14:55   ` Andreas Schwab
2020-09-29  7:57   ` Florian Weimer
2020-09-29 12:37     ` Adhemerval Zanella [this message]
2020-09-29 12:58       ` Adhemerval Zanella
2020-09-29 13:01         ` Florian Weimer
2020-09-29 13:04           ` Adhemerval Zanella
2020-09-28 14:45 ` [PATCH 4/6] sysvipc: Return EINVAL for invalid msgctl commands Adhemerval Zanella
2020-09-29  7:58   ` Florian Weimer
2020-09-29 13:26     ` Adhemerval Zanella
2020-09-29 17:05       ` Florian Weimer
2020-09-28 14:45 ` [PATCH 5/6] sysvipc: Fix IPC_INFO and SHM_INFO handling [BZ #26636] Adhemerval Zanella
2020-09-28 14:45 ` [PATCH 6/6] sysvipc: Return EINVAL for invalid shmctl commands Adhemerval Zanella
2020-09-28 14:59 ` [PATCH 1/6] sysvipc: Fix SEM_STAT_ANY kernel argument pass [BZ #26637] Florian Weimer
2020-09-28 21:06   ` Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1b71983c-db12-a6ff-692d-1ab3bd784758@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=ldv@altlinux.org \
    --cc=libc-alpha@sourceware.org \
    --cc=robert@ocallahan.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).