]> wimlib.net Git - wimlib/blobdiff - src/inode.c
Use explicit casting in ctype macros
[wimlib] / src / inode.c
index 6277f0c427d678e49959240963921a898e160ec3..690eb22f3abf657ef51b354e030e85fe00eec8ac 100644 (file)
@@ -342,11 +342,13 @@ inode_replace_stream_data(struct wim_inode *inode,
                          const void *data, size_t size,
                          struct blob_table *blob_table)
 {
-       struct blob_descriptor *new_blob;
+       struct blob_descriptor *new_blob = NULL;
 
-       new_blob = new_blob_from_data_buffer(data, size, blob_table);
-       if (!new_blob)
-               return false;
+       if (size) {
+               new_blob = new_blob_from_data_buffer(data, size, blob_table);
+               if (!new_blob)
+                       return false;
+       }
 
        inode_replace_stream_blob(inode, strm, new_blob, blob_table);
        return true;
@@ -378,16 +380,18 @@ inode_add_stream_with_data(struct wim_inode *inode,
                           struct blob_table *blob_table)
 {
        struct wim_inode_stream *strm;
-       struct blob_descriptor *blob;
+       struct blob_descriptor *blob = NULL;
 
        strm = inode_add_stream(inode, stream_type, stream_name, NULL);
        if (!strm)
                return false;
 
-       blob = new_blob_from_data_buffer(data, size, blob_table);
-       if (!blob) {
-               inode_remove_stream(inode, strm, blob_table);
-               return false;
+       if (size) {
+               blob = new_blob_from_data_buffer(data, size, blob_table);
+               if (unlikely(!blob)) {
+                       inode_remove_stream(inode, strm, blob_table);
+                       return false;
+               }
        }
 
        inode_set_stream_blob(inode, strm, blob);
@@ -494,8 +498,8 @@ blob_not_found_error(const struct wim_inode *inode, const u8 *hash)
 }
 
 /*
- * Return the blob descriptor for the specified stream, or NULL if the blob for
- * the stream is empty or not available.
+ * Return the blob descriptor for the specified stream, or NULL if the stream is
+ * empty or its blob is not available in @table.
  */
 struct blob_descriptor *
 stream_blob(const struct wim_inode_stream *strm, const struct blob_table *table)
@@ -519,9 +523,9 @@ stream_hash(const struct wim_inode_stream *strm)
 
 /*
  * Return the blob descriptor for the unnamed data stream of the inode, or NULL
- * if the inode does not have an unnamed data stream, the blob for the inode's
- * unnamed data stream is empty, or the blob for the inode's unnamed data stream
- * is not available in @blob_table.
+ * if the inode does not have an unnamed data stream, the inode's unnamed data
+ * stream is empty, or the blob for the inode's unnamed data stream is not
+ * available in @blob_table.
  */
 struct blob_descriptor *
 inode_get_blob_for_unnamed_data_stream(const struct wim_inode *inode,