I don't understand why nr is a pointer to unsigned char. If it is a pointer to char, the code is much cleaner.
* device/cirbuf.c (getc) (nr): Use char instead of unsigned char. (getc) (c_cf, c_cl): Don't cast to (unsigned char *). (getc) (c_end, c_start): Likewise. (getc) (nr): Don't cast to (char *). --- device/cirbuf.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/device/cirbuf.c b/device/cirbuf.c index 292b888..491e89c 100644 --- a/device/cirbuf.c +++ b/device/cirbuf.c @@ -103,19 +103,19 @@ int putc( */ int getc(struct cirbuf *cb) { - unsigned char *nr; + char *nr; int c; - nr = (unsigned char *)cb->c_cf; - if (nr == (unsigned char *)cb->c_cl) { + nr = cb->c_cf; + if (nr == cb->c_cl) { CB_CHECK(cb); return -1; /* empty */ } c = *nr; nr++; - if (nr == (unsigned char *)cb->c_end) - nr = (unsigned char *)cb->c_start; - cb->c_cf = (char *)nr; + if (nr == cb->c_end) + nr = cb->c_start; + cb->c_cf = nr; cb->c_cc--; -- 1.8.1.4