Revision: 77680
          http://sourceforge.net/p/brlcad/code/77680
Author:   brlcad
Date:     2020-11-04 14:36:19 +0000 (Wed, 04 Nov 2020)
Log Message:
-----------
oepl cleanup, ws, and tidy up a big bu_log

Modified Paths:
--------------
    brlcad/trunk/src/librt/db5_io.c

Modified: brlcad/trunk/src/librt/db5_io.c
===================================================================
--- brlcad/trunk/src/librt/db5_io.c     2020-11-04 14:34:58 UTC (rev 77679)
+++ brlcad/trunk/src/librt/db5_io.c     2020-11-04 14:36:19 UTC (rev 77680)
@@ -53,31 +53,40 @@
 {
     const struct db5_ondisk_header *odp = (const struct db5_ondisk_header *)hp;
 
-    if (odp->db5h_magic1 != DB5HDR_MAGIC1) return 0;
-    if (hp[7] != DB5HDR_MAGIC2) return 0;
+    if (odp->db5h_magic1 != DB5HDR_MAGIC1)
+       return 0;
+    if (hp[7] != DB5HDR_MAGIC2)
+       return 0;
 
     /* hflags */
     if ((odp->db5h_hflags & DB5HDR_HFLAGS_DLI_MASK) != 
DB5HDR_HFLAGS_DLI_HEADER_OBJECT)
        return 0;
-    if ((odp->db5h_hflags & DB5HDR_HFLAGS_NAME_PRESENT)) return 0;
-    if (((odp->db5h_hflags & DB5HDR_HFLAGS_OBJECT_WIDTH_MASK) >> 
DB5HDR_HFLAGS_OBJECT_WIDTH_SHIFT)
-       != DB5HDR_WIDTHCODE_8BIT) return 0;
+    if ((odp->db5h_hflags & DB5HDR_HFLAGS_NAME_PRESENT))
+       return 0;
+    if (((odp->db5h_hflags & DB5HDR_HFLAGS_OBJECT_WIDTH_MASK) >> 
DB5HDR_HFLAGS_OBJECT_WIDTH_SHIFT) != DB5HDR_WIDTHCODE_8BIT)
+       return 0;
 
     /* aflags */
-    if ((odp->db5h_aflags & DB5HDR_AFLAGS_ZZZ_MASK) != DB5_ZZZ_UNCOMPRESSED) 
return 0;
-    if (odp->db5h_aflags & DB5HDR_AFLAGS_PRESENT) return 0;
-    if (((odp->db5h_aflags & DB5HDR_AFLAGS_WIDTH_MASK) >> 
DB5HDR_AFLAGS_WIDTH_SHIFT)
-       != DB5HDR_WIDTHCODE_8BIT) return 0;
+    if ((odp->db5h_aflags & DB5HDR_AFLAGS_ZZZ_MASK) != DB5_ZZZ_UNCOMPRESSED)
+       return 0;
+    if (odp->db5h_aflags & DB5HDR_AFLAGS_PRESENT)
+       return 0;
+    if (((odp->db5h_aflags & DB5HDR_AFLAGS_WIDTH_MASK) >> 
DB5HDR_AFLAGS_WIDTH_SHIFT) != DB5HDR_WIDTHCODE_8BIT)
+       return 0;
 
     /* bflags */
-    if ((odp->db5h_bflags & DB5HDR_BFLAGS_ZZZ_MASK) != DB5_ZZZ_UNCOMPRESSED) 
return 0;
-    if (odp->db5h_bflags & DB5HDR_BFLAGS_PRESENT) return 0;
-    if (((odp->db5h_bflags & DB5HDR_BFLAGS_WIDTH_MASK) >> 
DB5HDR_BFLAGS_WIDTH_SHIFT)
-       != DB5HDR_WIDTHCODE_8BIT) return 0;
+    if ((odp->db5h_bflags & DB5HDR_BFLAGS_ZZZ_MASK) != DB5_ZZZ_UNCOMPRESSED)
+       return 0;
+    if (odp->db5h_bflags & DB5HDR_BFLAGS_PRESENT)
+       return 0;
+    if (((odp->db5h_bflags & DB5HDR_BFLAGS_WIDTH_MASK) >> 
DB5HDR_BFLAGS_WIDTH_SHIFT) != DB5HDR_WIDTHCODE_8BIT)
+       return 0;
 
     /* major and minor type */
-    if (odp->db5h_major_type != DB5_MAJORTYPE_RESERVED) return 0;
-    if (odp->db5h_minor_type != 0) return 0;
+    if (odp->db5h_major_type != DB5_MAJORTYPE_RESERVED)
+       return 0;
+    if (odp->db5h_minor_type != 0)
+       return 0;
 
     /* Check length, known to be 8-bit.  Header len=1 8-byte chunk. */
     if (hp[6] != 1)
@@ -86,12 +95,16 @@
     return 1;          /* valid */
 }
 
+
 int
 db5_select_length_encoding(size_t len)
 {
-    if (len <= 255) return DB5HDR_WIDTHCODE_8BIT;
-    if (len <= 65535) return DB5HDR_WIDTHCODE_16BIT;
-    if (len < 0x7ffffffe) return DB5HDR_WIDTHCODE_32BIT;
+    if (len <= 255)
+       return DB5HDR_WIDTHCODE_8BIT;
+    if (len <= 65535)
+       return DB5HDR_WIDTHCODE_16BIT;
+    if (len < 0x7ffffffe)
+       return DB5HDR_WIDTHCODE_32BIT;
     return DB5HDR_WIDTHCODE_64BIT;
 }
 
@@ -121,6 +134,7 @@
     return 0;
 }
 
+
 size_t
 db5_decode_signed(size_t *lenp, const unsigned char *cp, int format)
 {
@@ -215,22 +229,15 @@
     rip->major_type = cp[4];
     rip->minor_type = cp[5];
 
-    if (RT_G_DEBUG&RT_DEBUG_DB) bu_log("crack_disk_header()\n\
-       h_dli=%d, h_object_width=%d, h_name_present=%d, h_name_width=%d, \n\
-       a_width=%d, a_present=%d, a_zzz=%d, \n\
-       b_width=%d, b_present=%d, b_zzz=%d, major=%d, minor=%d\n",
-                                   rip->h_dli,
-                                   rip->h_object_width,
-                                   rip->h_name_present,
-                                   rip->h_name_width,
-                                   rip->a_width,
-                                   rip->a_present,
-                                   rip->a_zzz,
-                                   rip->b_width,
-                                   rip->b_present,
-                                   rip->b_zzz,
-                                   rip->major_type,
-                                   rip->minor_type);
+    if (RT_G_DEBUG&RT_DEBUG_DB) {
+       bu_log("crack_disk_header()\n"
+              "\th_dli=%d, h_object_width=%d, h_name_present=%d, 
h_name_width=%d,\n"
+              "\ta_width=%d, a_present=%d, a_zzz=%d,\n"
+              "\tb_width=%d, b_present=%d, b_zzz=%d, major=%d, minor=%d\n",
+              rip->h_dli, rip->h_object_width, rip->h_name_present, 
rip->h_name_width,
+              rip->a_width, rip->a_present, rip->a_zzz,
+              rip->b_width, rip->b_present, rip->b_zzz, rip->major_type, 
rip->minor_type);
+    }
 
     return 0;
 }
@@ -241,7 +248,8 @@
 {
     const unsigned char *cp = ip;
 
-    if (crack_disk_header(rip, cp) < 0) return NULL;
+    if (crack_disk_header(rip, cp) < 0)
+       return NULL;
     cp += sizeof(struct db5_ondisk_header);
 
     cp += db5_decode_length(&rip->object_length, cp, rip->h_object_width);
@@ -248,8 +256,7 @@
     rip->object_length <<= 3;  /* cvt 8-byte chunks to byte count */
 
     if ((size_t)rip->object_length < sizeof(struct db5_ondisk_header)) {
-       bu_log("db5_get_raw_internal_ptr(): object_length=%ld is too short, 
database possibly corrupted\n",
-              rip->object_length);
+       bu_log("db5_get_raw_internal_ptr(): object_length=%ld is too short, 
database possibly corrupted\n", rip->object_length);
        return NULL;
     }
 
@@ -265,8 +272,7 @@
 
     /* Grab name, if present */
     if (rip->h_name_present) {
-       cp += db5_decode_length(&rip->name.ext_nbytes,
-                               cp, rip->h_name_width);
+       cp += db5_decode_length(&rip->name.ext_nbytes, cp, rip->h_name_width);
        rip->name.ext_buf = (uint8_t *)cp;      /* discard const */
        cp += rip->name.ext_nbytes;
     }
@@ -273,8 +279,7 @@
 
     /* Point to attributes, if present */
     if (rip->a_present) {
-       cp += db5_decode_length(&rip->attributes.ext_nbytes,
-                               cp, rip->a_width);
+       cp += db5_decode_length(&rip->attributes.ext_nbytes, cp, rip->a_width);
        rip->attributes.ext_buf = (uint8_t *)cp;        /* discard const */
 #if defined(USE_BINARY_ATTRIBUTES)
        rip->attributes.widcode = rip->a_width;
@@ -284,8 +289,7 @@
 
     /* Point to body, if present */
     if (rip->b_present) {
-       cp += db5_decode_length(&rip->body.ext_nbytes,
-                               cp, rip->b_width);
+       cp += db5_decode_length(&rip->body.ext_nbytes, cp, rip->b_width);
        rip->body.ext_buf = (uint8_t *)cp;      /* discard const */
        cp += rip->body.ext_nbytes;
     }
@@ -295,6 +299,7 @@
     return ip + rip->object_length;
 }
 
+
 int
 db5_get_raw_internal_fp(struct db5_raw_internal *rip, FILE *fp)
 {
@@ -307,7 +312,8 @@
     unsigned char *cp;
 
     if (fread((unsigned char *)&header, sizeof header, 1, fp) != 1) {
-       if (feof(fp)) return -1;
+       if (feof(fp))
+           return -1;
        bu_log("db5_get_raw_internal_fp(): fread header error\n");
        return -2;
     }
@@ -380,8 +386,7 @@
 
     /* Grab name, if present */
     if (rip->h_name_present) {
-       cp += db5_decode_length(&rip->name.ext_nbytes,
-                               cp, rip->h_name_width);
+       cp += db5_decode_length(&rip->name.ext_nbytes, cp, rip->h_name_width);
        rip->name.ext_buf = (uint8_t *)cp;      /* discard const */
        cp += rip->name.ext_nbytes;
     }
@@ -388,8 +393,7 @@
 
     /* Point to attributes, if present */
     if (rip->a_present) {
-       cp += db5_decode_length(&rip->attributes.ext_nbytes,
-                               cp, rip->a_width);
+       cp += db5_decode_length(&rip->attributes.ext_nbytes, cp, rip->a_width);
        rip->attributes.ext_buf = (uint8_t *)cp;        /* discard const */
 #if defined(USE_BINARY_ATTRIBUTES)
        rip->attributes.widcode = rip->a_width;
@@ -399,8 +403,7 @@
 
     /* Point to body, if present */
     if (rip->b_present) {
-       cp += db5_decode_length(&rip->body.ext_nbytes,
-                               cp, rip->b_width);
+       cp += db5_decode_length(&rip->body.ext_nbytes, cp, rip->b_width);
        rip->body.ext_buf = (uint8_t *)cp;      /* discard const */
        cp += rip->body.ext_nbytes;
     }
@@ -408,6 +411,7 @@
     return 0;          /* success */
 }
 
+
 void
 db5_export_object3(
     struct bu_external *out,
@@ -560,6 +564,7 @@
     BU_ASSERT(out->ext_nbytes >= 8);
 }
 
+
 void
 db5_make_free_object_hdr(struct bu_external *ep, size_t length)
 {
@@ -589,6 +594,7 @@
     db5_encode_length(cp, length>>3, h_width);
 }
 
+
 void
 db5_make_free_object(struct bu_external *ep, size_t length)
 {
@@ -620,6 +626,7 @@
     *cp = DB5HDR_MAGIC2;
 }
 
+
 int
 rt_db_cvt_to_external5(
     struct bu_external *ext,
@@ -690,6 +697,7 @@
     return 0;          /* OK */
 }
 
+
 int
 db_wrap_v5_external(struct bu_external *ep, const char *name)
 {
@@ -732,6 +740,7 @@
     return 0;
 }
 
+
 int
 db_put_external5(struct bu_external *ep, struct directory *dp, struct db_i 
*dbip)
 {
@@ -740,7 +749,7 @@
     BU_CK_EXTERNAL(ep);
 
     if (RT_G_DEBUG&RT_DEBUG_DB) bu_log("db_put_external5(%s) ep=%p, dbip=%p, 
dp=%p\n",
-                                   dp->d_namep, (void *)ep, (void *)dbip, 
(void *)dp);
+                                      dp->d_namep, (void *)ep, (void *)dbip, 
(void *)dp);
 
     if (dbip->dbi_read_only) {
        bu_log("db_put_external5(%s):  READ-ONLY file\n",
@@ -777,6 +786,7 @@
     return 0;
 }
 
+
 int
 rt_db_put_internal5(
     struct directory *dp,
@@ -874,7 +884,8 @@
     if ((raw.major_type == DB5_MAJORTYPE_BRLCAD)
        ||(raw.major_type == DB5_MAJORTYPE_BINARY_UNIF)) {
        /* As a convenience to older ft_import routines */
-       if (mat == NULL) mat = bn_mat_identity;
+       if (mat == NULL)
+           mat = bn_mat_identity;
     } else {
        bu_log("rt_db_external5_to_internal5(%s):  unable to import non-BRL-CAD 
object, major=%d minor=%d\n",
               name, raw.major_type, raw.minor_type);
@@ -946,6 +957,7 @@
     return id;                 /* OK */
 }
 
+
 int
 rt_db_get_internal5(
     struct rt_db_internal *ip,
@@ -981,6 +993,7 @@
     rt_vls_color_map(ostr);
 }
 
+
 void
 db5_import_color_table(char *cp)
 {
@@ -994,6 +1007,7 @@
     }
 }
 
+
 int
 db5_put_color_table(struct db_i *dbip)
 {
@@ -1012,6 +1026,7 @@
     return ret;
 }
 
+
 int
 db5_get_attributes(const struct db_i *dbip, struct bu_attribute_value_set 
*avs, const struct directory *dp)
 {
@@ -1046,6 +1061,7 @@
     return 0;
 }
 
+
 /** @} */
 /*
  * Local Variables:

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to