giftcurs-commits
[Top][All Lists]
Advanced

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

[giFTcurs-commits] giFTcurs/src format.c


From: Christian Häggström
Subject: [giFTcurs-commits] giFTcurs/src format.c
Date: Sat, 08 Nov 2003 10:12:37 -0500

CVSROOT:        /cvsroot/giftcurs
Module name:    giFTcurs
Branch:         
Changes by:     Christian Häggström <address@hidden>    03/11/08 10:12:36

Modified files:
        src            : format.c 

Log message:
        Unaligned write generates Bus Error on some architectures (sparc). Use 
memcpy instead.

Patches:
Index: giFTcurs/src/format.c
diff -u giFTcurs/src/format.c:1.71 giFTcurs/src/format.c:1.72
--- giFTcurs/src/format.c:1.71  Tue Nov  4 10:55:37 2003
+++ giFTcurs/src/format.c       Sat Nov  8 10:12:36 2003
@@ -18,7 +18,7 @@
  * along with giFTcurs; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,  USA.
  *
- * $Id: format.c,v 1.71 2003/11/04 15:55:37 saturn Exp $
+ * $Id: format.c,v 1.72 2003/11/08 15:12:36 saturn Exp $
  */
 #include "giftcurs.h"
 
@@ -210,13 +210,17 @@
                        /* big endian enables us to use memcmp */
                        if (!rev)
                                v.intval = ~v.intval;
-                       *((unsigned int *) bufp)++ = GINT_TO_BE(v.intval);
+                       v.intval = GINT_TO_BE(v.intval);
+                       memcpy(bufp, &v.intval, sizeof v.intval);
+                       bufp += sizeof v.intval;
                        break;
                case ATTR_LONG:
                        /* big endian enables us to use memcmp */
                        if (!rev)
                                v.longval = ~v.longval;
-                       *((guint64 *) bufp)++ = GINT64_TO_BE(v.intval);
+                       v.longval = GINT64_TO_BE(v.longval);
+                       memcpy(bufp, &v.longval, sizeof v.longval);
+                       bufp += sizeof v.longval;
                        break;
                case ATTR_NONE:
                        break;
@@ -229,7 +233,8 @@
        g_free(fmt0);
 
        /* end with the pointer value to prevent equal strings */
-       *((const void **) bufp)++ = item;
+       memcpy(bufp, &item, sizeof item);
+       bufp += sizeof item;
 
        if (*res && memcmp(*res, buf, bufp - buf) == 0)
                return 0;
@@ -328,7 +333,7 @@
                *p = ' ';
 }
 
-static int digits(unsigned int i)
+static G_GNUC_CONST int digits(unsigned int i)
 {
        int n;
 
@@ -339,7 +344,7 @@
        return n;
 }
 
-static int value_to_int(enum attr_type t, attr_value * v)
+static G_GNUC_PURE int value_to_int(enum attr_type t, attr_value * v)
 {
        switch (t) {
        case ATTR_STRLEN:
@@ -356,7 +361,7 @@
        assert_not_reached();
 }
 
-static guint64 value_to_long(enum attr_type t, attr_value * v)
+static G_GNUC_PURE guint64 value_to_long(enum attr_type t, attr_value * v)
 {
        if (t == ATTR_LONG)
                return v->longval;
@@ -364,7 +369,7 @@
                return value_to_int(t, v);
 }
 
-static int value_to_width(enum attr_type t, attr_value * v)
+static G_GNUC_PURE int value_to_width(enum attr_type t, attr_value * v)
 {
        switch (t) {
        case ATTR_STRLEN:
@@ -381,7 +386,7 @@
        assert_not_reached();
 }
 
-static const char *value_to_string(enum attr_type t, attr_value * v)
+static G_GNUC_PURE const char *value_to_string(enum attr_type t, attr_value * 
v)
 {
        switch (t) {
        case ATTR_STRLEN:
@@ -398,7 +403,7 @@
        assert_not_reached();
 }
 
-static unsigned int attribute_int(char *attr, struct format_ctrl *k);
+static G_GNUC_PURE unsigned int attribute_int(char *attr, struct format_ctrl 
*k);
 
 static enum attr_type attribute_get(char *attr, struct format_ctrl *k, 
attr_value * value)
 {
@@ -427,14 +432,14 @@
        return k->getattr(k->udata, attr, value);
 }
 
-static unsigned int attribute_int(char *attr, struct format_ctrl *k)
+static G_GNUC_PURE unsigned int attribute_int(char *attr, struct format_ctrl 
*k)
 {
        attr_value value;
 
        return value_to_int(attribute_get(attr, k, &value), &value);
 }
 
-static guint64 attribute_long(char *attr, struct format_ctrl *k)
+static G_GNUC_PURE guint64 attribute_long(char *attr, struct format_ctrl *k)
 {
        attr_value value;
 




reply via email to

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