svn rev #22568: trunk/src/lib/krb5/ccache/

raeburn@MIT.EDU raeburn at MIT.EDU
Fri Aug 21 14:32:46 EDT 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=22568
Commit By: raeburn
Log Message:
Use {load,store}_{16,32}_be for big-endian integers.


Changed Files:
U   trunk/src/lib/krb5/ccache/cc_file.c
Modified: trunk/src/lib/krb5/ccache/cc_file.c
===================================================================
--- trunk/src/lib/krb5/ccache/cc_file.c	2009-08-21 17:52:51 UTC (rev 22567)
+++ trunk/src/lib/krb5/ccache/cc_file.c	2009-08-21 18:32:46 UTC (rev 22568)
@@ -725,7 +725,6 @@
     krb5_fcc_data *data = (krb5_fcc_data *)id->data;
     krb5_error_code retval;
     unsigned char buf[4];
-    krb5_int32 val;
 
     k5_cc_mutex_assert_locked(context, &((krb5_fcc_data *) id->data)->lock);
 
@@ -736,11 +735,7 @@
 	retval = krb5_fcc_read(context, id, buf, 4);
 	if (retval)
 	    return retval;
-        val = buf[0];
-        val = (val << 8) | buf[1];
-        val = (val << 8) | buf[2];
-        val = (val << 8) | buf[3];
-        *i = val;
+        *i = load_32_be (buf);
 	return 0;
     }
 }
@@ -761,7 +756,7 @@
 	retval = krb5_fcc_read(context, id, buf, 2);
 	if (retval)
 	    return retval;
-	*i = (buf[0] << 8) + buf[1];
+	*i = load_16_be (buf);
 	return 0;
     }
 }    
@@ -1077,13 +1072,7 @@
 	(data->version == KRB5_FCC_FVNO_2)) 
 	return krb5_fcc_write(context, id, (char *) &i, sizeof(krb5_int32));
     else {
-        buf[3] = (unsigned char) (i & 0xFF);
-	i >>= 8;
-        buf[2] = (unsigned char) (i & 0xFF);
-	i >>= 8;
-        buf[1] = (unsigned char) (i & 0xFF);
-	i >>= 8;
-        buf[0] = (unsigned char) (i & 0xFF);
+	store_32_be (i, buf);
 	return krb5_fcc_write(context, id, buf, 4);
     }
 }
@@ -1102,9 +1091,7 @@
         ibuf = (krb5_ui_2) i;
 	return krb5_fcc_write(context, id, (char *) &ibuf, sizeof(krb5_ui_2));
     } else {
-        buf[1] = (unsigned char) (i & 0xFF);
-	i >>= 8;
-        buf[0] = (unsigned char) (i & 0xFF);
+	store_16_be (i, buf);
 	return krb5_fcc_write(context, id, buf, 2);
     }
 }




More information about the cvs-krb5 mailing list