Examples of errors detected by the V627 diagnostic


V627. Consider inspecting the expression. The argument of sizeof() is the macro which expands to a number.


Samba

V627 Consider inspecting the expression. The argument of sizeof() is the macro which expands to a number. regfio.c 1470


#define HBIN_HDR_SIZE    4

char header[HBIN_HDR_SIZE];

static REGF_HBIN* regf_hbin_allocate(REGF_FILE *file,
                                     uint32 block_size)
{
  REGF_HBIN *hbin;
  ....
  memcpy( hbin->header, "hbin", sizeof(HBIN_HDR_SIZE) );
  ....
}

It works. Good luck: sizeof(4) == 4.


Network Security Services (NSS)

V627 Consider inspecting the expression. The argument of sizeof() is the macro which expands to a number. ssl3ext.c 1541


#define SSL3_MASTER_SECRET_LENGTH 48

SECStatus
ssl3_ServerHandleSessionTicketXtn(....)
{
  if (buffer_len < sizeof(SSL3_MASTER_SECRET_LENGTH))
    goto no_ticket;
  ....
}

Data Distribution Service

V627 Consider inspecting the expression. The argument of sizeof() is the macro which expands to a number. test_position_independent_malloc.cpp 61


static void *
initialize (TEST_MALLOC *allocator)
{
  ....
  ACE_ALLOCATOR_RETURN (gap,
                        allocator->malloc (sizeof (256)),
                        0);
  ....
}

Similar errors can be found in some other places:

  • V627 Consider inspecting the expression. The argument of sizeof() is the macro which expands to a number. malloc_test.cpp 168

WebRTC

V627 Consider inspecting the expression. The argument of sizeof() is the macro which expands to a number. fsmdef.c 4481


#define CC_MAX_DIALSTRING_LEN (512)

static sm_rcs_t
fsmdef_ev_idle_feature (sm_event_t *event)
{
  ....
  memset(data->newcall.redirect.redirects[0].number, 0,
         sizeof(CC_MAX_DIALSTRING_LEN));
  ....
}

Similar errors can be found in some other places:

  • V627 Consider inspecting the expression. The argument of sizeof() is the macro which expands to a number. fsmdef.c 4508
  • V627 Consider inspecting the expression. The argument of sizeof() is the macro which expands to a number. fsmxfr.c 800
  • V627 Consider inspecting the expression. The argument of sizeof() is the macro which expands to a number. fsmxfr.c 1600

Haiku Operation System

V627 Consider inspecting the expression. The argument of sizeof() is the macro which expands to a number. device.c 72


#define PCI_line_size 0x0c /* (1 byte) cache line size in 32 bit words */

static status_t
wb840_open(const char* name, uint32 flags, void** cookie)
{
  ....
  data->wb_cachesize = gPci->read_pci_config(data->pciInfo->bus,
    data->pciInfo->device, data->pciInfo->function, PCI_line_size,
    sizeof(PCI_line_size)) & 0xff;
  ....
}


Bugs Found

Checked Projects
364
Collected Errors
13 504