]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/bitmap.c
Merge pull request #10201 from yuwata/fix-10196
[thirdparty/systemd.git] / src / basic / bitmap.c
index f4b12fc261460a3e6f27d739ebb3f929806e890f..a4cd6451b0c0adf34d15862b8873c5a36698ca48 100644 (file)
@@ -1,21 +1,4 @@
-/***
-  This file is part of systemd.
-
-  Copyright 2015 Tom Gundersen
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
+/* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
 #include <stddef.h>
@@ -58,10 +41,8 @@ Bitmap *bitmap_copy(Bitmap *b) {
                 return NULL;
 
         ret->bitmaps = newdup(uint64_t, b->bitmaps, b->n_bitmaps);
-        if (!ret->bitmaps) {
-                free(ret);
-                return NULL;
-        }
+        if (!ret->bitmaps)
+                return mfree(ret);
 
         ret->n_bitmaps = ret->bitmaps_allocated = b->n_bitmaps;
         return ret;
@@ -225,7 +206,7 @@ bool bitmap_equal(Bitmap *a, Bitmap *b) {
                 return true;
 
         common_n_bitmaps = MIN(a->n_bitmaps, b->n_bitmaps);
-        if (memcmp(a->bitmaps, b->bitmaps, sizeof(uint64_t) * common_n_bitmaps) != 0)
+        if (memcmp_safe(a->bitmaps, b->bitmaps, sizeof(uint64_t) * common_n_bitmaps) != 0)
                 return false;
 
         c = a->n_bitmaps > b->n_bitmaps ? a : b;