Revision a8a358bf

b/target-i386/helper.c
349 349
    char *featurestr, *name = strtok(s, ",");
350 350
    uint32_t plus_features = 0, plus_ext_features = 0, plus_ext2_features = 0, plus_ext3_features = 0;
351 351
    uint32_t minus_features = 0, minus_ext_features = 0, minus_ext2_features = 0, minus_ext3_features = 0;
352
    int family = -1, model = -1, stepping = -1;
352
    uint32_t numvalue;
353 353

  
354 354
    def = NULL;
355 355
    for (i = 0; i < ARRAY_SIZE(x86_defs); i++) {
......
381 381
            *val = 0; val++;
382 382
            if (!strcmp(featurestr, "family")) {
383 383
                char *err;
384
                family = strtol(val, &err, 10);
385
                if (!*val || *err || family < 0) {
384
                numvalue = strtoul(val, &err, 0);
385
                if (!*val || *err) {
386 386
                    fprintf(stderr, "bad numerical value %s\n", val);
387 387
                    goto error;
388 388
                }
389
                x86_cpu_def->family = family;
389
                x86_cpu_def->family = numvalue;
390 390
            } else if (!strcmp(featurestr, "model")) {
391 391
                char *err;
392
                model = strtol(val, &err, 10);
393
                if (!*val || *err || model < 0 || model > 0xff) {
392
                numvalue = strtoul(val, &err, 0);
393
                if (!*val || *err || numvalue > 0xff) {
394 394
                    fprintf(stderr, "bad numerical value %s\n", val);
395 395
                    goto error;
396 396
                }
397
                x86_cpu_def->model = model;
397
                x86_cpu_def->model = numvalue;
398 398
            } else if (!strcmp(featurestr, "stepping")) {
399 399
                char *err;
400
                stepping = strtol(val, &err, 10);
401
                if (!*val || *err || stepping < 0 || stepping > 0xf) {
400
                numvalue = strtoul(val, &err, 0);
401
                if (!*val || *err || numvalue > 0xf) {
402 402
                    fprintf(stderr, "bad numerical value %s\n", val);
403 403
                    goto error;
404 404
                }
405
                x86_cpu_def->stepping = stepping;
405
                x86_cpu_def->stepping = numvalue ;
406
            } else if (!strcmp(featurestr, "level")) {
407
                char *err;
408
                numvalue = strtoul(val, &err, 0);
409
                if (!*val || *err) {
410
                    fprintf(stderr, "bad numerical value %s\n", val);
411
                    goto error;
412
                }
413
                x86_cpu_def->level = numvalue;
414
            } else if (!strcmp(featurestr, "xlevel")) {
415
                char *err;
416
                numvalue = strtoul(val, &err, 0);
417
                if (!*val || *err) {
418
                    fprintf(stderr, "bad numerical value %s\n", val);
419
                    goto error;
420
                }
421
                if (numvalue < 0x80000000) {
422
                	numvalue += 0x80000000;
423
                }
424
                x86_cpu_def->xlevel = numvalue;
406 425
            } else if (!strcmp(featurestr, "vendor")) {
407 426
                if (strlen(val) != 12) {
408 427
                    fprintf(stderr, "vendor string must be 12 chars long\n");

Also available in: Unified diff