KOVACS Krisztian wrote: > Hi, > > On Thursday 18 January 2007 14:38, Jonas Berlin wrote: > >>| Better check that divisor must be != 0 inside div64_64. >> >>I initially suggested that too and would have renamed the function to >>div64_64_safe() or similar in the same go.. but Hidden (on irc) thought >>it was up to the caller to do the checking, and I felt he probably >>knows the kernel way of thinking better than me and succumbed. :) I >>think it's up to Patrick, I'm really only concerned with that it gets >>fixed :) If Patrick so requests, I'll redo it the other way.. > > > Not that it matters a lot, but I thought determining what to do if there > have been no packets yet does not belong to the division routine > logically. For me at least, it would introduce some kind of obscurity: at > a first glance you won't be able to see what happens if packets==0, > you'll have to scroll up to the div() function. Choosing zero as the > average packet length in the corner case is appropriate only because > that's whay usually makes sense in your ruleset. (For example if you use > connbytes to classify traffic into bulk and interactive categories based > on the average packet length, 0 as the "fallback" value is OK because it > means that a brand new connection is considered interactive.) > > I guess this is a matter of personal preference: one way it's less code, > the other way it's easier to read -- at least for me. Of course the only > thing that matters is having this bug fixed, as it's quite ugly indeed. I agree that having the caller check it is easier to read. I'm wondering what value to use when packets == 0 though, it can't happen for the first packet of a connection since it has already been accounted for before we can match, so the packets counter must have overflown at least once (and the byte counter at least as often as the packet counter). Well, I guess it doesn't matter since we've lost anyway, so I've queued this patch.