Print this page
12826 update to smatch 0.6.1-rc1-il-6

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/check_kernel_printf.c
          +++ new/usr/src/tools/smatch/src/check_kernel_printf.c
↓ open down ↓ 7 lines elided ↑ open up ↑
   8    8   *
   9    9   * This program is distributed in the hope that it will be useful,
  10   10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11   11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12   12   * GNU General Public License for more details.
  13   13   *
  14   14   * You should have received a copy of the GNU General Public License
  15   15   * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
  16   16   */
  17   17  
       18 +#define _GNU_SOURCE
       19 +
  18   20  #include <assert.h>
  19   21  #include <ctype.h>
  20   22  #include <string.h>
  21   23  #include "smatch.h"
  22   24  #include "smatch_slist.h"
  23   25  
  24   26  #define spam(args...) do {                      \
  25   27          if (option_spammy)                      \
  26   28                  sm_msg(args);                   \
  27   29          } while (0)
↓ open down ↓ 172 lines elided ↑ open up ↑
 200  202          spec->base = 10;
 201  203          switch (*fmt) {
 202  204          case 'c':
 203  205                  if (qualifier)
 204  206                          sm_warning("qualifier '%c' ignored for %%c specifier", qualifier);
 205  207  
 206  208                  spec->type = FORMAT_TYPE_CHAR;
 207  209                  return ++fmt - start;
 208  210  
 209  211          case 's':
 210      -                if (qualifier)
      212 +                if (qualifier && qualifier != 'l')
 211  213                          sm_warning("qualifier '%c' ignored for %%s specifier", qualifier);
 212  214  
 213  215                  spec->type = FORMAT_TYPE_STR;
 214  216                  return ++fmt - start;
 215  217  
 216  218          case 'p':
 217  219                  spec->type = FORMAT_TYPE_PTR;
 218  220                  return ++fmt - start;
 219  221  
 220  222          case '%':
↓ open down ↓ 444 lines elided ↑ open up ↑
 665  667          type = get_type(arg);
 666  668          if (!type) {
 667  669                  sm_warning("could not determine type of argument %d", vaidx);
 668  670                  return;
 669  671          }
 670  672          if (!is_ptr_type(type)) {
 671  673                  sm_error("%%p expects pointer argument, but argument %d has type '%s'",
 672  674                          vaidx, type_to_str(type));
 673  675                  return;
 674  676          }
      677 +
      678 +        /* error pointers */
      679 +        if (*fmt == 'e')
      680 +                fmt++;
      681 +
      682 +
 675  683          /* Just plain %p, nothing to check. */
 676  684          if (!isalnum(*fmt))
 677  685                  return;
 678  686  
 679  687          basetype = get_real_base_type(type);
 680  688          if (is_void_type(basetype))
 681  689                  return;
 682  690          /*
 683  691           * Passing a pointer-to-array is harmless, but most likely one
 684  692           * meant to pass pointer-to-first-element. If basetype is
↓ open down ↓ 795 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX