[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
rtems-980923 is available
- Date: Wed, 23 Sep 1998 15:02:35 -0500 (CDT)
- From: joel at oarcorp.com (joel at oarcorp.com)
- Subject: rtems-980923 is available
On Wed, 23 Sep 1998, Eric Norum wrote:
> I think the best solution here is to have
> rtems_termios_dequeue_characters return 0 if the last characters have
> been dequeued and return 1 if they have not.
> That's the way the return value is being used now.
> In fact, I am sure I sent a patch with this change several weeks ago
> -- it must have gotten lost in the shuffle.
There have been so many changes to the return value from this function
that I have lost track of which is in now or not. :)
I think the libchip tree has yet another variant on this. The dequeue
function returns nothing and it checks the state afterwards. This was not
that clean since the state was a private value.
> The change is so small that I'm including it in this message.
> diff -u -r rtems-980923.orig/c/src/lib/libc/termios.c
> --- rtems-980923.orig/c/src/lib/libc/termios.c Wed Sep 23 07:20:29 1998
> +++ rtems-980923/c/src/lib/libc/termios.c Wed Sep 23 13:13:42 1998
> @@ -928,8 +928,5 @@
> tty->rawOutBufState = rob_busy;
> tty->rawOutBufTail = newTail;
> - return nToSend;
> + return 1;
> BTW -- Sorry about this, Joel. I realize that keeping all these
> submissions straight is tough enough without the rest of us getting
> into disagreements like this.
:) This one has flip-flopped a lot. I think I personally argued about
this a while back. It started with two things:
+ making this routine safe to call when nothing was enqueued, and
+ getting a return value/indicator back.
I personally like the "is there something there?"
But in all fairness, returning the count is an indicator of that as well.
You have to treat it as zero or non-zero then which is technically how a
lot of C routines are defined anyway. The problem would come when you use
it as a loop counter.
<stepping up on the podium>
RTEMS routines should have precise semantics and the return values should
have accurate meanings. If 0 or 1 is all that is reliable, then that is
what it should be. A count is more useful but if it is not accurate, then
someone will eventually lose.