Skip to content

ManifestPkgOperations() could reuse PkgRecordShouldBeReplaced() #90

Open

Description

@djbclark

PkgRecordShouldBeReplaced() (cf-agent/simulate_mode.c, added for upstream cfengine#6424) is used by DiffPkgOperations(). ManifestPkgOperations() keeps an inline copy of the same rule for the present map (simulate_mode.c ~L1004-1008, on 94b2157):

if ((prev_record == NULL) ||
    (NULL_OR_EMPTY(prev_record->pkg_ver) && !NULL_OR_EMPTY(pkg_ver)) ||
    (!NULL_OR_EMPTY(pkg_ver) && !NULL_OR_EMPTY(prev_record->pkg_ver) &&
     PkgVersionIsGreater(pkg_ver, prev_record->pkg_ver)))

That condition is logically equivalent to PkgRecordShouldBeReplaced(prev_record, pkg_ver), so it could call the helper. The absent map uses a different rule (it prefers the unversioned record) and stays as is.

Not a bug, just duplication. Offer upstream only if a maintainer raises it on cfengine#6424, or as a separate small PR after cfengine#6424 lands (one upstream PR at a time).

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions