Skip to content

Is the check avail >= SIMPLEFS_MAX_EXTENTS actually necessary here? #81

Description

@RoyWFHuang

The purpose of this check is to prevent avail from going out of bounds, but I think it may not be necessary.

/* Validate avail index is within bounds */
if (avail >= SIMPLEFS_MAX_EXTENTS) {
    ret = -EMLINK;
    goto iput;
}

Whenever functions like "simplefs_create" are called, we already validate the maximum number of files with:

if (eblock->nr_files == SIMPLEFS_MAX_SUBFILES)

If this check passes, it means there is guaranteed to be space for creating a new object under this directory. Therefore, simplefs_get_available_ext_idx() should never return an out-of-bound value, and this boundary check appears redundant.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions