Print this page
11200 cpcgen needs smatch fixes again

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/cpcgen/cpcgen.c
          +++ new/usr/src/tools/cpcgen/cpcgen.c
↓ open down ↓ 2 lines elided ↑ open up ↑
   3    3   * Common Development and Distribution License ("CDDL"), version 1.0.
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13      - * Copyright (c) 2019, Joyent, Inc.
       13 + * Copyright 2019, Joyent, Inc.
  14   14   */
  15   15  
  16   16  /*
  17   17   * This program transforms Intel perfmon and AMD PMC data files into C files and
  18   18   * manual pages.
  19   19   */
  20   20  
  21   21  #include <stdio.h>
  22   22  #include <stdarg.h>
  23   23  #include <unistd.h>
↓ open down ↓ 388 lines elided ↑ open up ↑
 412  412          }
 413  413          step = strtok_r(NULL, "-", &last);
 414  414  
 415  415          if (strcmp(bstr, brand) != 0) {
 416  416                  errx(EXIT_FAILURE, "brand string \"%s\" did not match \"%s\"",
 417  417                      brand, bstr);
 418  418          }
 419  419  
 420  420          errno = 0;
 421  421          l = strtol(fam, &last, 16);
 422      -        if (errno != 0 || l < 0 || l > UINT_MAX || *last != '\0') {
      422 +        if (errno != 0 || l < 0 || l >= INT_MAX || *last != '\0') {
 423  423                  errx(EXIT_FAILURE, "failed to parse family \"%s\"", fam);
 424  424          }
 425  425          *family = (uint_t)l;
 426  426  
 427  427          l = strtol(mod, &last, 16);
 428      -        if (errno != 0 || l < 0 || l > UINT_MAX || *last != '\0') {
      428 +        if (errno != 0 || l < 0 || l >= INT_MAX || *last != '\0') {
 429  429                  errx(EXIT_FAILURE, "failed to parse model \"%s\"", mod);
 430  430          }
 431  431          *model = (uint_t)l;
 432  432  
 433  433          if (step == NULL) {
 434  434                  *nstepp = 0;
 435  435                  return;
 436  436          }
 437  437  
 438  438          if (*step != '[' || ((last = strrchr(step, ']')) == NULL)) {
↓ open down ↓ 446 lines elided ↑ open up ↑
 885  885                          }
 886  886                  }
 887  887          }
 888  888  
 889  889          if (fprintf(f, cpcgen_manual_intel_data) == -1) {
 890  890                  warn("failed to write out manual header for %s",
 891  891                      map->cmap_name);
 892  892                  return (B_FALSE);
 893  893          }
 894  894  
 895      -        free(upper);
 896  895          return (B_TRUE);
 897  896  }
 898  897  
 899  898  static boolean_t
 900  899  cpcgen_manual_intel_file_after(FILE *f, cpc_map_t *map)
 901  900  {
 902  901          if (fprintf(f, cpcgen_manual_intel_trailer) == -1) {
 903  902                  warn("failed to write out manual header for %s",
 904  903                      map->cmap_name);
 905  904                  return (B_FALSE);
↓ open down ↓ 1141 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX