On Mon, 2010-09-27 at 14:19 +0300, Martin Paljak wrote: > Hello, > On Sep 26, 2010, at 2:55 PM, Andre Zepezauer wrote: > > > On Sun, 2010-09-26 at 09:22 +0300, Martin Paljak wrote: > >> Hello, > >> On Sun, Sep 26, 2010 at 08:47, Andre Zepezauer > >> <andre.zepeza...@student.uni-halle.de> wrote: > >>> With the current trunk 2048b keys on CardOS are working again. Therefore > >>> the max_*_size patches work for me. But I have two suggestions: > >>> > >>> [1] The intended overriding will not work, if the card has a default > >>> value of zero for max_*_size. If this is the case, then limitations > >>> imposed by the reader are not honoured. > >> It would be a programming error, which does not make sense. Åšetting > >> this to 0 would mean "I'm a card and I can't receive or send data, but > >> here is my 1K LOC driver nevertheless". > > > > The value of max_*_size actually defaults to zero [3] and will stay so, > > if not overridden by the card driver. See how it is used in the > > iso-driver. IMHO zero is a legal value and means that no restrictions > > are imposed by the card. Same is true for reader drivers. > I managed to mis-explain my own idea. > Yes, you are right, the values default to zero which means "no limitations" > (not "zero bytes") > And yes, the overriding check is bogus if card does not impose limitations > before the reader does. Will fix.
I would do it this way: /* Override card limitations with reader limitations. * Note that zero means no limitations at all. */ if ((card->max_recv_size == 0) || ((reader->driver->max_recv_size != 0) && (reader->driver->max_recv_size < card->max_recv_size))) { card->max_recv_size = reader->driver->max_recv_size; } if ((card->max_send_size == 0) || ((reader->driver->max_send_size != 0) && (reader->driver->max_send_size < card->max_send_size))) { card->max_send_size = reader->driver->max_send_size; } _______________________________________________ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel