trafficserver icon indicating copy to clipboard operation
trafficserver copied to clipboard

Is this missed to pass argument in `plugins/multiplexer/dispatch.cc`?

Open freak82 opened this issue 1 year ago • 1 comments

Hi there,

There is this read function in plugins/multiplexer/dispatch.cc:

uint64_t
read(const TSIOBuffer &b, std::string &o, const int64_t l = 0)
{
  TSIOBufferReader reader = TSIOBufferReaderAlloc(b);
  const uint64_t   length = read(reader, o);
  TSIOBufferReaderFree(reader);
  return length;
}

and it internally calls an overload of the same function

uint64_t
read(const TSIOBufferReader &r, std::string &o, int64_t l = 0)

I think the first function should also forward the l argument to the overload version but it doesn't. Currently this doesn't seem to break anything because of the current usages of the read functions. So, does this need to be fixed?

freak82 avatar May 21 '24 08:05 freak82

It looks like the both read functions are only used to read whole data in a buffer. Forwarding the l argument is a valid change, but I'd remove the l arguments from the both. I don't think it's worth keeping them because they are local functions and we can add them back easily if needed.

maskit avatar May 22 '24 16:05 maskit

It seems to me that this version of the function uint64_t read(const TSIOBufferReader &r, std::string &o, int64_t l = 0) is called by void Handler::data(const TSIOBufferReader r, const int64_t l) where the l argument is passed to the read function. So, it seems that I can't remove it from there. Maybe I misunderstood what you wrote above?

freak82 avatar May 24 '24 04:05 freak82

Ah, I missed the use in Handler::data. Then just from the TSIOBuffer version.

maskit avatar May 24 '24 16:05 maskit