Re: [PATCH v4 02/35] pkt-line: allow peeking a packet line without consuming it

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

 



On 03/01, Junio C Hamano wrote:
> Brandon Williams <bmwill@xxxxxxxxxx> writes:
> 
> > +enum packet_read_status packet_reader_read(struct packet_reader *reader)
> > +{
> > +	if (reader->line_peeked) {
> > +		reader->line_peeked = 0;
> > +		return reader->status;
> > +	}
> > +
> > +	reader->status = packet_read_with_status(reader->fd,
> > +						 &reader->src_buffer,
> > +						 &reader->src_len,
> > +						 reader->buffer,
> > +						 reader->buffer_size,
> > +						 &reader->pktlen,
> > +						 reader->options);
> > +
> > +	switch (reader->status) {
> > +	case PACKET_READ_EOF:
> > +		reader->pktlen = -1;
> > +		reader->line = NULL;
> > +		break;
> > +	case PACKET_READ_NORMAL:
> > +		reader->line = reader->buffer;
> > +		break;
> > +	case PACKET_READ_FLUSH:
> > +		reader->pktlen = 0;
> > +		reader->line = NULL;
> > +		break;
> > +	}
> > +
> > +	return reader->status;
> > +}
> 
> With the way _peek() interface interacts with the reader instance
> (which by the way I find is well designed), it is understandable
> that we want almost everything available in reader's fields, but
> having to manually clear pktlen field upon non NORMAL status feels
> a bit strange.  
> 
> Perhaps that is because the underlying packet_read_with_status()
> does not set *pktlen in these cases?  Shouldn't it be doing that so
> the caller does not have to?

That's true, I'll fix that.


-- 
Brandon Williams



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux