Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 203600
b: refs/heads/master
c: c974138
h: refs/heads/master
v: v3
  • Loading branch information
Andy Shevchenko authored and David S. Miller committed Jul 16, 2010
1 parent 62a7082 commit be5f941
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 61 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3944ad6848e7ae15a3402372a2df4ae805008321
refs/heads/master: c9741380d32a58d685cfa0aa8d22bdb3bbeeb8aa
80 changes: 20 additions & 60 deletions trunk/drivers/isdn/gigaset/ev-layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,64 +385,18 @@ static const struct zsau_resp_t {
{NULL, ZSAU_UNKNOWN}
};

/*
* Get integer from char-pointer
*/
static int isdn_getnum(char *p)
{
int v = -1;

gig_dbg(DEBUG_EVENT, "string: %s", p);

while (*p >= '0' && *p <= '9')
v = ((v < 0) ? 0 : (v * 10)) + (int) ((*p++) - '0');
if (*p)
v = -1; /* invalid Character */
return v;
}

/*
* Get integer from char-pointer
*/
static int isdn_gethex(char *p)
{
int v = 0;
int c;

gig_dbg(DEBUG_EVENT, "string: %s", p);

if (!*p)
return -1;

do {
if (v > (INT_MAX - 15) / 16)
return -1;
c = *p;
if (c >= '0' && c <= '9')
c -= '0';
else if (c >= 'a' && c <= 'f')
c -= 'a' - 10;
else if (c >= 'A' && c <= 'F')
c -= 'A' - 10;
else
return -1;
v = v * 16 + c;
} while (*++p);

return v;
}

/* retrieve CID from parsed response
* returns 0 if no CID, -1 if invalid CID, or CID value 1..65535
*/
static int cid_of_response(char *s)
{
int cid;
unsigned long cid;
int rc;

if (s[-1] != ';')
return 0; /* no CID separator */
cid = isdn_getnum(s);
if (cid < 0)
rc = strict_strtoul(s, 10, &cid);
if (rc)
return 0; /* CID not numeric */
if (cid < 1 || cid > 65535)
return -1; /* CID out of range */
Expand Down Expand Up @@ -612,21 +566,27 @@ void gigaset_handle_modem_response(struct cardstate *cs)
case RT_ZCAU:
event->parameter = -1;
if (curarg + 1 < params) {
i = isdn_gethex(argv[curarg]);
j = isdn_gethex(argv[curarg + 1]);
if (i >= 0 && i < 256 && j >= 0 && j < 256)
event->parameter = (unsigned) i << 8
| j;
curarg += 2;
unsigned long type, value;

i = strict_strtoul(argv[curarg++], 16, &type);
j = strict_strtoul(argv[curarg++], 16, &value);

if (i == 0 && type < 256 &&
j == 0 && value < 256)
event->parameter = (type << 8) | value;
} else
curarg = params - 1;
break;
case RT_NUMBER:
event->parameter = -1;
if (curarg < params) {
event->parameter = isdn_getnum(argv[curarg]);
++curarg;
} else
event->parameter = -1;
unsigned long res;
int rc;

rc = strict_strtoul(argv[curarg++], 10, &res);
if (rc == 0)
event->parameter = res;
}
gig_dbg(DEBUG_EVENT, "parameter==%d", event->parameter);
break;
}
Expand Down

0 comments on commit be5f941

Please sign in to comment.