# Buggy code
def swaps():
    """
    Return a dict containing information on active swap

    CLI Example:

    .. code-block:: bash

        salt '*' mount.swaps
    """
    ret = {}
    if __grains__["os"] != "OpenBSD":
        with salt.utils.fopen("/proc/swaps") as fp_:
            for line in fp_:
                if line.startswith("Filename"):
                    continue
                comps = line.split()
                ret[comps[0]] = {
                    "type": comps[1],
                    "size": comps[2],
                    "used": comps[3],
                    "priority": comps[4],
                }
    else:
        for line in __salt__["cmd.run_stdout"]("swapctl -kl").splitlines():
            if line.startswith(("Device", "Total")):
                continue
            swap_type = "file"
            comps = line.split()
            if comps[0].startswith("/dev/"):
                swap_type = "partition"
            ret[comps[0]] = {
                "type": swap_type,
                "size": comps[1],
                "used": comps[2],
                "priority": comps[5],
            }
    return ret


# Traceback (IndexError)
[ERROR   ] Command 'mount -l' failed with return code: 1
[ERROR   ] stderr: mount: illegal option -- l
Usage:
mount [-v | -p]
mount [-F FSType] [-V] [current_options] [-o specific_options]
{special | mount_point}
mount [-F FSType] [-V] [current_options] [-o specific_options]
special mount_point
mount -a [-F FSType ] [-V] [current_options] [-o specific_options]
[mount_point ...]
[ERROR   ] An exception occurred in this state: Traceback (most recent call last):
File "salt/state.py", line 1379, in call
File "salt/states/mount.py", line 87, in mounted
File "salt/modules/mount.py", line 108, in active
File "salt/modules/mount.py", line 30, in _active_mountinfo
File "salt/modules/mount.py", line 25, in _list_mounts
IndexError: list index out of rang

# Fixed code
def swaps():
    """
    Return a dict containing information on active swap

    .. versionchanged:: 2016.3.2

    CLI Example:

    .. code-block:: bash

        salt '*' mount.swaps
    """
    ret = {}
    if __grains__["kernel"] == "SunOS":
        for line in __salt__["cmd.run_stdout"]("swap -l").splitlines():
            if line.startswith("swapfile"):
                continue
            comps = line.split()
            ret[comps[0]] = {
                "type": "device" if comps[0].startswith(("/dev", "swap")) else "file",
                "size": int(comps[3]),
                "used": (int(comps[3]) - int(comps[4])),
                "priority": "-",
            }
    elif __grains__["os"] != "OpenBSD":
        with salt.utils.fopen("/proc/swaps") as fp_:
            for line in fp_:
                if line.startswith("Filename"):
                    continue
                comps = line.split()
                ret[comps[0]] = {
                    "type": comps[1],
                    "size": comps[2],
                    "used": comps[3],
                    "priority": comps[4],
                }
    else:
        for line in __salt__["cmd.run_stdout"]("swapctl -kl").splitlines():
            if line.startswith(("Device", "Total")):
                continue
            swap_type = "file"
            comps = line.split()
            if comps[0].startswith("/dev/"):
                swap_type = "partition"
            ret[comps[0]] = {
                "type": swap_type,
                "size": comps[1],
                "used": comps[2],
                "priority": comps[5],
            }
    return ret