bug-mailutils
[Top][All Lists]
Advanced

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

Re: Sergey(patch mbx_mbox.c)


From: Sergey Poznyakoff
Subject: Re: Sergey(patch mbx_mbox.c)
Date: Tue, 24 Apr 2001 10:58:58 +0300

> I know it's confusing 8-).  In other words this function should return
> true if the mailbox __is__ updated i.e. when the size that we hold
> internally and the current size of the mailbox(file) are the same.

But then its return value is inconsistent. The function reads:

static int
mbox_is_updated (mailbox_t mailbox)
{
  off_t size = 0;
  mbox_data_t mud = mailbox->data;
  if (stream_size (mailbox->stream, &size) != 0)
    return 0;
  if (size < mud->size)
    {
      observable_notify (mailbox->observable, MU_EVT_MAILBOX_CORRUPT);
      /* And be verbose.  ? */
      fprintf (stderr, "* BAD : Mailbox corrupted, shrank size\n");
      /* FIXME: should I crash.  */
      return 1;
    }
  return (mud->size == size);
}

So, it returns 1 from `if (size < mud->size)' block when the mailbox
size *has changed*, but it also returns 1 when (mud->size == size), that
is when the mailbox size *has not changed*.

I suppose it should rather be:

static int
mbox_is_updated (mailbox_t mailbox)
{
  off_t size = 0;
  mbox_data_t mud = mailbox->data;
  if (mud->size == 0)
    return 1;
  if (stream_size (mailbox->stream, &size) != 0)
    return 0;
  if (size < mud->size)
    {
      observable_notify (mailbox->observable, MU_EVT_MAILBOX_CORRUPT);
      /* And be verbose.  ? */
      error("* BAD : Mailbox corrupted, shrank size");
      /* FIXME: should I crash.  */
      return 0;
    }
  return (mud->size == size);
}


-Sergey



reply via email to

[Prev in Thread] Current Thread [Next in Thread]