Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/plugin_apis/swap.api
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef enum {
BD_SWAP_TECH_MODE_ACTIVATE_DEACTIVATE = 1 << 1,
BD_SWAP_TECH_MODE_QUERY = 1 << 2,
BD_SWAP_TECH_MODE_SET_LABEL = 1 << 3,
BD_SWAP_TECH_MODE_SET_UUID = 1 << 3,
BD_SWAP_TECH_MODE_SET_UUID = 1 << 4,
} BDSwapTechMode;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/nvdimm.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ BDNVDIMMNamespaceInfo** bd_nvdimm_list_namespaces (const gchar *bus_name, const
continue;

ndctl_region_foreach (bus, region) {
if (region_name && g_strcmp0 (bus_name, ndctl_region_get_devname (region)) != 0)
if (region_name && g_strcmp0 (region_name, ndctl_region_get_devname (region)) != 0)
continue;

ndctl_namespace_foreach (region, ndns) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef enum {
BD_SWAP_TECH_MODE_ACTIVATE_DEACTIVATE = 1 << 1,
BD_SWAP_TECH_MODE_QUERY = 1 << 2,
BD_SWAP_TECH_MODE_SET_LABEL = 1 << 3,
BD_SWAP_TECH_MODE_SET_UUID = 1 << 3,
BD_SWAP_TECH_MODE_SET_UUID = 1 << 4,
Comment on lines 29 to +30
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== References to the public flag and ABI boundary =="
rg -n -C2 '\b(BDSwapTechMode|BD_SWAP_TECH_MODE_SET_UUID|bd_swap_is_tech_avail\s*\()' .

echo
echo "== Build/install/versioning metadata =="
rg -n -C2 'swap\.h|swap\.api|install_headers|gnome\.generate_gir|soversion|version-info|LT_VERSION|current:revision:age' \
  -g 'meson.build' -g 'configure.ac' -g 'Makefile.am' -g '*.pc.in' -g '*.map' -g '*.symbols' -g '*.gir' .

Repository: storaged-project/libblockdev

Length of output: 15170


This enum renumbering breaks the public ABI.

swap.h is installed as public API (Makefile.am:175), and BDSwapTechMode values are compiled directly into client binaries. Renumbering BD_SWAP_TECH_MODE_SET_UUID from 1 << 3 to 1 << 4 means old clients will pass 1 << 3 to bd_swap_is_tech_avail(), which the updated library now silently interprets as BD_SWAP_TECH_MODE_SET_LABEL. This corrupts the operation without error. Pair this with a soversion bump (currently -version-info 3:0:0) and/or a compatibility release note.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/plugins/swap.h` around lines 29 - 30, The enum renumbering changed public
ABI: restore the original bit values for BD_SWAP_TECH_MODE_SET_LABEL and
BD_SWAP_TECH_MODE_SET_UUID in swap.h so existing binaries continue to pass the
same integer flags to bd_swap_is_tech_avail(); do not change assigned bit-shifts
for BDSwapTechMode values, or if you must change them, add a compatibility layer
that accepts the old bit values and maps them to the new ones and update the
SONAME/soversion (and document the incompatibility in release notes) so callers
are not silently misinterpreted.

} BDSwapTechMode;

/*
Expand Down
4 changes: 2 additions & 2 deletions tests/part_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,10 +1236,10 @@ def test_set_part_uuid(self):

# we should still get proper data back
self.assertTrue(ps)
self.assertIn(ps.uuid, ("", None)) # no name
self.assertIn(ps.uuid, ("", None)) # no uuid

with self.assertRaises(GLib.GError):
BlockDev.part_set_part_name (self.loop_devs[0], ps.path, self.test_uuid)
BlockDev.part_set_part_uuid (self.loop_devs[0], ps.path, self.test_uuid)


class PartSetTypeCase(PartTestCase):
Expand Down
Loading