All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: Lists and aliasing (Re: Freeze on 27 February)
Date: Tue, 21 Feb 2012 21:29:08 +0100	[thread overview]
Message-ID: <4F43FE94.3040401@gmail.com> (raw)
In-Reply-To: <20120221195838.GA24235@caffeine.csclub.uwaterloo.ca>

[-- Attachment #1: Type: text/plain, Size: 553 bytes --]

On 21.02.2012 20:58, Lennart Sorensen wrote:
> On Tue, Feb 21, 2012 at 01:46:27PM -0500, Lennart Sorensen wrote:
>> That actually seems to have done it.  I am still trying to wrap my head
>> around why that made a difference since it appears to be identical code
>> moved somewhere else.  It isn't inlined anymore, but should that make
>> a big difference?
>>
>> Only 509 warnings left (down from 5000 or so).
> Using gcc 4.6 drops that to 199 warnings, so gcc 4.4 is a bit more whiny
> than 4.6.
>


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: warn.diff --]
[-- Type: text/x-diff; name="warn.diff", Size: 14280 bytes --]

diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/configure.ac mainline-mod/configure.ac
--- mainline/configure.ac	2012-02-21 14:29:15.000000000 +0100
+++ mainline-mod/configure.ac	2012-02-21 20:18:57.327763779 +0100
@@ -377,7 +377,7 @@
 LIBS=""
 
 # debug flags.
-WARN_FLAGS="-Wall -W -Wshadow -Wold-style-declaration -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Warray-bounds -Wattributes -Wbuiltin-macro-redefined -Wcast-align -Wchar-subscripts -Wclobbered -Wcomment -Wcoverage-mismatch -Wdeprecated -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-contains-nul -Wformat-extra-args -Wformat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wunsafe-loop-optimizations -Wlogical-op -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmudflap -Wmultichar -Wnonnull -Woverflow -Wpacked-bitfield-compat -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector -Wstrict-aliasing -Wswitch -Wsync-nand -Wtrigraphs  -Wtype-limits -Wundef -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-result -Wunused-value  -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wmissing-declarations -Wmissing-parameter-type  -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
+WARN_FLAGS="-Wall -W -Wshadow -Wold-style-declaration -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Warray-bounds -Wattributes -Wbuiltin-macro-redefined -Wcast-align -Wchar-subscripts -Wclobbered -Wcomment -Wcoverage-mismatch -Wdeprecated -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-contains-nul -Wformat-extra-args -Wformat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wunsafe-loop-optimizations -Wlogical-op -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmudflap -Wmultichar -Wnonnull -Woverflow -Wpacked-bitfield-compat -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wsync-nand -Wtrigraphs  -Wtype-limits -Wundef -Wuninitialized -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-result -Wunused-value  -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wmissing-declarations -Wmissing-parameter-type  -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS"
 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes"
 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/grub-core/commands/testload.c mainline-mod/grub-core/commands/testload.c
--- mainline/grub-core/commands/testload.c	2012-02-08 00:13:14.000000000 +0100
+++ mainline-mod/grub-core/commands/testload.c	2012-02-21 20:57:08.003762787 +0100
@@ -100,7 +100,10 @@
     {
       char sector[GRUB_DISK_SECTOR_SIZE];
 
-      pos -= GRUB_DISK_SECTOR_SIZE;
+      if (pos >= GRUB_DISK_SECTOR_SIZE)
+	pos -= GRUB_DISK_SECTOR_SIZE;
+      else
+	pos = 0;
 
       grub_file_seek (file, pos);
 
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/grub-core/fs/affs.c mainline-mod/grub-core/fs/affs.c
--- mainline/grub-core/fs/affs.c	2012-01-29 18:28:10.000000000 +0100
+++ mainline-mod/grub-core/fs/affs.c	2012-02-21 21:05:56.271763053 +0100
@@ -143,7 +143,7 @@
   mod = (grub_uint32_t) fileblock % data->htsize;
   /* Find the block that points to the fileblock we are looking up by
      following the chain until the right table is reached.  */
-  for (curblock = node->last_block_cache + 1; curblock <= target; curblock++)
+  for (curblock = node->last_block_cache + 1; curblock < target + 1; curblock++)
     {
       grub_disk_read (data->disk,
 		      node->block_cache[curblock - 1] + data->blocksize - 1,
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/grub-core/kern/corecmd.c mainline-mod/grub-core/kern/corecmd.c
--- mainline/grub-core/kern/corecmd.c	2012-02-12 15:26:18.000000000 +0100
+++ mainline-mod/grub-core/kern/corecmd.c	2012-02-21 20:50:07.351761943 +0100
@@ -128,7 +128,7 @@
   else
     {
       char *device_name;
-      grub_device_t dev;
+      grub_device_t dev = 0;
       grub_fs_t fs;
       char *path;
 
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/grub-core/kern/disk.c mainline-mod/grub-core/kern/disk.c
--- mainline/grub-core/kern/disk.c	2012-02-11 18:19:04.000000000 +0100
+++ mainline-mod/grub-core/kern/disk.c	2012-02-21 19:22:18.931756689 +0100
@@ -660,7 +660,7 @@
 	    goto finish;
 
 	  sector += (1 << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
-	  buf = (char *) buf + len;
+	  buf = (const char *) buf + len;
 	  size -= len;
 	  real_offset = 0;
 	}
@@ -678,7 +678,7 @@
 	  while (n--)
 	    grub_disk_cache_invalidate (disk->dev->id, disk->id, sector++);
 
-	  buf = (char *) buf + len;
+	  buf = (const char *) buf + len;
 	  size -= len;
 	}
     }
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/grub-core/kern/emu/hostdisk.c mainline-mod/grub-core/kern/emu/hostdisk.c
--- mainline/grub-core/kern/emu/hostdisk.c	2012-02-10 00:25:33.000000000 +0100
+++ mainline-mod/grub-core/kern/emu/hostdisk.c	2012-02-21 19:49:41.495760624 +0100
@@ -1145,8 +1145,9 @@
   int lineno = 0;
   struct stat st;
 
-  auto void show_error (const char *msg);
-  void show_error (const char *msg)
+  auto void show_error (const char *msg)
+    __attribute__ ((noreturn));
+  void __attribute__ ((noreturn)) show_error (const char *msg)
     {
       grub_util_error ("%s:%d: %s", dev_map, lineno, msg);
     }
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/grub-core/kern/list.c mainline-mod/grub-core/kern/list.c
--- mainline/grub-core/kern/list.c	2012-01-24 13:19:05.000000000 +0100
+++ mainline-mod/grub-core/kern/list.c	2012-02-21 20:13:45.891763027 +0100
@@ -68,3 +68,24 @@
   if (! inactive)
     nitem->prio |= GRUB_PRIO_LIST_FLAG_ACTIVE;
 }
+
+void
+grub_list_push (grub_list_t *head, grub_list_t item)
+{
+  item->prev = head;
+  if (*head)
+    (*head)->prev = &item->next;
+  item->next = *head;
+  *head = item;
+}
+
+void
+grub_list_remove (grub_list_t item)
+{
+  if (item->prev)
+    *item->prev = item->next;
+  if (item->next)
+    item->next->prev = item->prev;
+  item->next = 0;
+  item->prev = 0;
+}
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/grub-core/lib/pbkdf2.c mainline-mod/grub-core/lib/pbkdf2.c
--- mainline/grub-core/lib/pbkdf2.c	2012-02-09 15:13:25.000000000 +0100
+++ mainline-mod/grub-core/lib/pbkdf2.c	2012-02-21 21:00:08.475756929 +0100
@@ -70,13 +70,13 @@
 
   grub_memcpy (tmp, S, Slen);
 
-  for (i = 1; i <= l; i++)
+  for (i = 1; i - 1 < l; i++)
     {
       grub_memset (T, 0, hLen);
 
-      for (u = 1; u <= c; u++)
+      for (u = 0; u < c; u++)
 	{
-	  if (u == 1)
+	  if (u == 0)
 	    {
 	      tmp[Slen + 0] = (i & 0xff000000) >> 24;
 	      tmp[Slen + 1] = (i & 0x00ff0000) >> 16;
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/grub-core/lib/xzembed/xz_dec_bcj.c mainline-mod/grub-core/lib/xzembed/xz_dec_bcj.c
--- mainline/grub-core/lib/xzembed/xz_dec_bcj.c	2010-12-01 15:45:43.000000000 +0100
+++ mainline-mod/grub-core/lib/xzembed/xz_dec_bcj.c	2012-02-21 21:10:05.895761645 +0100
@@ -168,7 +168,7 @@
 	size_t i;
 	uint32_t instr;
 
-	for (i = 0; i + 4 <= size; i += 4) {
+	for (i = 0; i + 3 < size; i += 4) {
 		instr = get_unaligned_be32(buf + i);
 		if ((instr & 0xFC000003) == 0x48000001) {
 			instr &= 0x03FFFFFC;
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/grub-core/net/net.c mainline-mod/grub-core/net/net.c
--- mainline/grub-core/net/net.c	2012-02-21 16:15:54.000000000 +0100
+++ mainline-mod/grub-core/net/net.c	2012-02-21 20:54:22.291756835 +0100
@@ -608,8 +608,8 @@
 			struct grub_net_network_level_interface **interf)
 {
   struct grub_net_route *route;
-  int depth = 0;
-  int routecnt = 0;
+  unsigned depth = 0;
+  unsigned routecnt = 0;
   struct grub_net_network_level_protocol *prot = NULL;
   grub_net_network_level_address_t curtarget = addr;
 
@@ -618,7 +618,7 @@
   FOR_NET_ROUTES(route)
     routecnt++;
 
-  for (depth = 0; depth < routecnt + 2; depth++)
+  for (depth = 0; depth < routecnt + 2 && depth != (unsigned) -1; depth++)
     {
       struct grub_net_route *bestroute = NULL;
       FOR_NET_ROUTES(route)
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/grub-core/normal/charset.c mainline-mod/grub-core/normal/charset.c
--- mainline/grub-core/normal/charset.c	2012-02-09 22:27:51.000000000 +0100
+++ mainline-mod/grub-core/normal/charset.c	2012-02-21 21:04:33.019756480 +0100
@@ -608,7 +608,7 @@
   {
     struct grub_unicode_glyph t;
     unsigned i, tl;
-    for (i = 0; i <= (end - start) / 2; i++)
+    for (i = 0; i < (end - start) / 2 + 1; i++)
       {
 	t = visual[start + i];
 	visual[start + i] = visual[end - i];
@@ -665,7 +665,7 @@
 	  {
 	    unsigned j;	  
 	    /* FIXME: can be optimized.  */
-	    for (j = max_level; j >= min_odd_level; j--)
+	    for (j = max_level; j > min_odd_level - 1; j--)
 	      {
 		unsigned in = 0;
 		unsigned i;
@@ -734,7 +734,7 @@
 	  {
 	    int right_join = 0;
 	    signed i;
-	    for (i = k - 1; i >= (signed) line_start; i--)
+	    for (i = k - 1; i > (signed) line_start - 1; i--)
 	      {
 		enum grub_join_type join_type = get_join_type (visual[i].base);
 		if (!(visual[i].attributes
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/grub-core/normal/cmdline.c mainline-mod/grub-core/normal/cmdline.c
--- mainline/grub-core/normal/cmdline.c	2012-02-12 15:26:18.000000000 +0100
+++ mainline-mod/grub-core/normal/cmdline.c	2012-02-21 21:09:16.035762789 +0100
@@ -49,13 +49,13 @@
       /* Remove the lines that don't fit in the new buffer.  */
       if (newsize < hist_used)
 	{
-	  int i;
-	  int delsize = hist_used - newsize;
+	  grub_ssize_t i;
+	  grub_ssize_t delsize = hist_used - newsize;
 	  hist_used = newsize;
 
-	  for (i = 1; i <= delsize; i++)
+	  for (i = 1; i < delsize + 1; i++)
 	    {
-	      int pos = hist_end - i;
+	      grub_ssize_t pos = hist_end - i;
 	      if (pos < 0)
 		pos += hist_size;
 	      grub_free (old_hist_lines[pos]);
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/include/grub/list.h mainline-mod/include/grub/list.h
--- mainline/include/grub/list.h	2012-02-21 16:15:01.000000000 +0100
+++ mainline-mod/include/grub/list.h	2012-02-21 20:13:45.891763027 +0100
@@ -31,26 +31,8 @@
 };
 typedef struct grub_list *grub_list_t;
 
-static inline void
-grub_list_push (grub_list_t *head, grub_list_t item)
-{
-  item->prev = head;
-  if (*head)
-    (*head)->prev = &item->next;
-  item->next = *head;
-  *head = item;
-}
-
-static inline void
-grub_list_remove (grub_list_t item)
-{
-  if (item->prev)
-    *item->prev = item->next;
-  if (item->next)
-    item->next->prev = item->prev;
-  item->next = 0;
-  item->prev = 0;
-}
+void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item);
+void EXPORT_FUNC(grub_list_remove) (grub_list_t item);
 
 #define FOR_LIST_ELEMENTS(var, list) for ((var) = (list); (var); (var) = (var)->next)
 
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/Makefile.util.def mainline-mod/Makefile.util.def
--- mainline/Makefile.util.def	2012-02-21 18:52:37.000000000 +0100
+++ mainline-mod/Makefile.util.def	2012-02-21 20:29:09.323764500 +0100
@@ -36,7 +36,7 @@
 
 library = {
   name = libgrubmods.a;
-  cflags = '$(CFLAGS_POSIX) -Wno-undef';
+  cflags = '$(CFLAGS_POSIX) -Wno-undef -Wno-error=logical-op -Wno-error=missing-noreturn';
   cppflags = '-I$(top_srcdir)/grub-core/lib/minilzo -I$(srcdir)/grub-core/lib/xzembed -DMINILZO_HAVE_CONFIG_H';
 
   common_nodist = grub_script.tab.c;
diff --exclude Makefile.util.am --exclude Makefile.in --exclude grub.info --exclude configure --exclude aclocal.m4 --exclude '*autom4te.cache*' -ur mainline/util/bin2h.c mainline-mod/util/bin2h.c
--- mainline/util/bin2h.c	2011-07-05 23:04:16.000000000 +0200
+++ mainline-mod/util/bin2h.c	2012-02-21 20:42:18.695761246 +0100
@@ -31,7 +31,7 @@
     {0, 0, 0, 0 }
   };
 
-static void
+static void __attribute__ ((noreturn))
 usage (int status)
 {
   if (status)

  reply	other threads:[~2012-02-21 20:29 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-21 16:12 Freeze on 27 February Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-21 16:19 ` Lennart Sorensen
2012-02-21 17:09   ` Lists and aliasing (Re: Freeze on 27 February) Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-21 18:46     ` Lennart Sorensen
2012-02-21 19:58       ` Lennart Sorensen
2012-02-21 20:29         ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2012-02-22 15:34           ` Lennart Sorensen
2012-02-22 15:50             ` Lennart Sorensen
2012-02-22 15:57               ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-22 16:18                 ` Lennart Sorensen
2012-02-22 16:25                   ` Lennart Sorensen
2012-02-22 16:43                     ` Lennart Sorensen
2012-02-22 16:50                     ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-22 17:16                       ` Lennart Sorensen
2012-02-22 17:35                         ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-22 17:41                           ` Lennart Sorensen
2012-02-22 17:46                             ` Lennart Sorensen
2012-02-22 18:01                               ` Lennart Sorensen
2012-02-22 18:28                                 ` Lennart Sorensen
2012-02-22 18:41                                   ` Lennart Sorensen
2012-02-22 19:00                                     ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-22 22:50                                       ` Lennart Sorensen
2012-02-22 23:03                                         ` Lennart Sorensen
2012-02-23  2:39                                           ` Isaac Dupree
2012-02-23  6:17                                           ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-23 17:43                                             ` Lennart Sorensen
2012-02-24 23:16                                               ` Lennart Sorensen
2012-02-22 17:38                         ` Lennart Sorensen
2012-02-22 16:51                   ` Lennart Sorensen
2012-02-21 21:40         ` Lennart Sorensen
2012-02-22  5:35 ` Freeze on 27 February Richard Laager
2012-02-23  6:34   ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-27  6:58     ` Richard Laager
2012-02-27 18:17       ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-27  7:32     ` Richard Laager
     [not found]     ` <1330033617.3895.26.camel@watermelon.coderich.net>
     [not found]       ` <4F4AC782.1090402@gmail.com>
     [not found]         ` <1330322499.2901.5.camel@watermelon.coderich.net>
     [not found]           ` <1330322681.2901.8.camel@watermelon.coderich.net>
2012-02-27 18:18             ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-27 18:20           ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-27 19:46             ` Richard Laager
2012-03-08 22:51               ` Remaining ZFS Changes for 2.00 (Was: Re: Freeze on 27 February) Richard Laager
2012-03-10 12:44                 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-10 13:39                 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-10 15:51                   ` Richard Laager
2012-03-10 16:01                     ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-10 13:41                 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-10 17:51                 ` Vladimir 'φ-coder/phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F43FE94.3040401@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.