[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] -Woverlength-strings / assert unhelpful interaction



$ gcc -O2 -c -Woverlength-strings stupid.c 
stupid.c: In function ‘insert_lf_record’:
stupid.c:22: warning: string length ‘7394’ is greater than the length ‘509’ ISO C90 compilers are required to support

Without -O2 the error message goes away.

Even ISO C99 compilers don't help - they raise the limit to a mere
4095 bytes.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

struct hive_h {
  void *addr;
};
struct ntreg_hbin_block {
  char id[2];
};
typedef size_t hive_node_h;

#define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
#define BLOCK_ID_EQ(h,offs,eqid) \
  (STREQLEN (((struct ntreg_hbin_block *)((h)->addr + (offs)))->id, (eqid), 2))

static size_t
insert_lf_record (struct hive_h *h, size_t old_offs, size_t posn,
                  const char *name, hive_node_h node)
{
  assert (BLOCK_ID_EQ (h, old_offs, "lf") || BLOCK_ID_EQ (h, old_offs, "lh"));
}

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]