bug-tar
[Top][All Lists]
Advanced

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

[Bug-tar] [PATCH] avoid compiler warning


From: Eric Blake
Subject: [Bug-tar] [PATCH] avoid compiler warning
Date: Fri, 8 May 2009 15:41:44 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

I noticed some use of undefined behavior of ctype macros (not all platforms 
guarantee that isxxx(char) produces sane results, when the high bit is set).  
Also, is there any reason that src/Makefile.in is stored in git, but not the 
toplevel Makefile.in?


From: Eric Blake <address@hidden>
Date: Fri, 8 May 2009 09:36:28 -0600
Subject: [PATCH] avoid undefined behavior

* src/xheader.c (xheader_set_keyword_equal): Pass correct type to
ctype macros.
* src/transform.c (run_case_conv): Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 src/transform.c |    9 ++++-----
 src/xheader.c   |    6 +++---
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/transform.c b/src/transform.c
index 2e0de31..03c06f6 100644
--- a/src/transform.c
+++ b/src/transform.c
@@ -430,21 +430,21 @@ run_case_conv (enum case_ctl_type case_ctl, char *ptr, 
size_t size)
   switch (case_ctl)
     {
     case ctl_upcase_next:
-      case_ctl_buffer[0] = toupper (case_ctl_buffer[0]);
+      case_ctl_buffer[0] = toupper ((unsigned char) case_ctl_buffer[0]);
       break;
       
     case ctl_locase_next:
-      case_ctl_buffer[0] = tolower (case_ctl_buffer[0]);
+      case_ctl_buffer[0] = tolower ((unsigned char) case_ctl_buffer[0]);
       break;
       
     case ctl_upcase:
       for (p = case_ctl_buffer; p < case_ctl_buffer + size; p++)
-       *p = toupper (*p);
+       *p = toupper ((unsigned char) *p);
       break;
       
     case ctl_locase:
       for (p = case_ctl_buffer; p < case_ctl_buffer + size; p++)
-       *p = tolower (*p);
+       *p = tolower ((unsigned char) *p);
       break;

     case ctl_stop:
@@ -628,4 +628,3 @@ transform_name (char **pinput, int type)
 {
   return transform_name_fp (pinput, type, NULL, NULL);
 }
-
diff --git a/src/xheader.c b/src/xheader.c
index 919ecd3..84ae08b 100644
--- a/src/xheader.c
+++ b/src/xheader.c
@@ -1,6 +1,6 @@
 /* POSIX extended headers for tar.

-   Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, 
Inc.

    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
@@ -168,12 +168,12 @@ xheader_set_keyword_equal (char *kw, char *eq)
       global = false;
     }

-  while (p > kw && isspace (*p))
+  while (p > kw && isspace ((unsigned char) *p))
     p--;

   *p = 0;

-  for (p = eq + 1; *p && isspace (*p); p++)
+  for (p = eq + 1; *p && isspace ((unsigned char) *p); p++)
     ;

   if (strcmp (kw, "delete") == 0)
-- 
1.6.2.4






reply via email to

[Prev in Thread] Current Thread [Next in Thread]