Skip to contentSkip to conversation

perf jit: add source line info support

bug report Dan Carpenter 2 participants 3 messages Nov 30, 2016 – Dec 10, 2016

lore
Share & tools
lore
#0 lore raw

Hello Stephane Eranian,

The patch 598b7c6919c7: "perf jit: add source line info support" from Nov 30, 2015, leads to the following static checker warning:

	./tools/perf/util/genelf_debug.c:211 emit_signed_LEB128()
	warn: potential left shift more than type allows '57'

./tools/perf/util/genelf_debug.c
202 static void emit_signed_LEB128(struct buffer_ext *be, long data) 203 {

   204          int more = 1;
   205          int negative = data < 0;
   206          int size = sizeof(long) * CHAR_BIT;
   207          while (more) {
   208                  ubyte cur = data & 0x7F;
   209                  data >>= 7;
   210                  if (negative)
   211                          data |= - (1 << (size - 7));
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is a no-op on 64 bit systems. I suspect it's not intentional?

   212                  if ((data == 0 && !(cur & 0x40)) ||
   213                      (data == -1l && (cur & 0x40)))
   214                          more = 0;
   215                  else
   216                          cur |= 0x80;
   217                  buffer_ext_add(be, &cur, 1);
   218          }
   219  }

regards,
dan carpenter

#1 lore raw

Hi Dan,

Quoted 20 lines · Dan Carpenter

Hello Stephane Eranian,

The patch 598b7c6919c7: "perf jit: add source line info support" from Nov 30, 2015, leads to the following static checker warning:

./tools/perf/util/genelf_debug.c:211 emit_signed_LEB128()
warn: potential left shift more than type allows '57'

./tools/perf/util/genelf_debug.c
202 static void emit_signed_LEB128(struct buffer_ext *be, long data)

   203  {
   204          int more = 1;
   205          int negative = data < 0;
   206          int size = sizeof(long) * CHAR_BIT;
   207          while (more) {
   208                  ubyte cur = data & 0x7F;
   209                  data >>= 7;
   210                  if (negative)
   211                          data |= - (1 << (size - 7));
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 2 lines

This is a no-op on 64 bit systems. I suspect it's not intentional?

I suspect size should be: size = sizeof(int) * CHAR_BIT; I will test that.

Quoted 11 lines
   212                  if ((data == 0 && !(cur & 0x40)) ||
   213                      (data == -1l && (cur & 0x40)))
   214                          more = 0;
   215                  else
   216                          cur |= 0x80;
   217                  buffer_ext_add(be, &cur, 1);
   218          }
   219  }

regards,
dan carpenter

#2 lore raw
Quoted 26 lines · Stephane Eranian

Hi Dan,

Quoted 20 lines · Dan Carpenter

Hello Stephane Eranian,

The patch 598b7c6919c7: "perf jit: add source line info support" from Nov 30, 2015, leads to the following static checker warning:

./tools/perf/util/genelf_debug.c:211 emit_signed_LEB128()
warn: potential left shift more than type allows '57'

./tools/perf/util/genelf_debug.c
202 static void emit_signed_LEB128(struct buffer_ext *be, long data)

   203  {
   204          int more = 1;
   205          int negative = data < 0;
   206          int size = sizeof(long) * CHAR_BIT;
   207          while (more) {
   208                  ubyte cur = data & 0x7F;
   209                  data >>= 7;
   210                  if (negative)
   211                          data |= - (1 << (size - 7));
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 2 lines

This is a no-op on 64 bit systems. I suspect it's not intentional?

Quoted 2 lines

I suspect size should be: size = sizeof(int) * CHAR_BIT; I will test that.

Sorry, I think the issue is on the 1 shift, should be 1UL instead.

Quoted 12 lines
Quoted 12 lines
   212                  if ((data == 0 && !(cur & 0x40)) ||
   213                      (data == -1l && (cur & 0x40)))
   214                          more = 0;
   215                  else
   216                          cur |= 0x80;
   217                  buffer_ext_add(be, &cur, 1);
   218          }
   219  }

regards,
dan carpenter