Project

General

Profile

Bug #11515

libzfs: fix and simplify error message handling in zfs_mount()

Added by Gergő Mihály Doma over 1 year ago.

Status:
New
Priority:
Low
Category:
lib - userland libraries
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

During browsing the code I have found these errors:
  • nested calling of dgettext()
  • unnecessary variable (buf[]) and snprintf()

This code (see here):

            char buf[256];
            int spa_version;

            VERIFY(zfs_spa_version(zhp, &spa_version) == 0);
            (void) snprintf(buf, sizeof (buf),
                dgettext(TEXT_DOMAIN, "Can't mount a version %lld " 
                "file system on a version %d pool. Pool must be" 
                " upgraded to mount this file system."),
                (u_longlong_t)zfs_prop_get_int(zhp,
                ZFS_PROP_VERSION), spa_version);
            zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, buf));

should look like:
            int spa_version;

            VERIFY(zfs_spa_version(zhp, &spa_version) == 0);
            zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                "Can't mount a version %lld file system on " 
                "a version %d pool. Pool must be upgraded to " 
                "mount this file system."),
                (u_longlong_t)zfs_prop_get_int(zhp,
                ZFS_PROP_VERSION), spa_version);

No data to display

Also available in: Atom PDF