Skip to content

Wrong assertion #2

@YichiZhang0613

Description

@YichiZhang0613

In btle-master/src/le/advertiser.rs, the assertion is inconsistent with comment, I think it should be assert!(map <= Self::ALL_U8, "invalid channel map {}", map);

impl ChannelMap {
...
    /// Creates a new `ChannelMap`.
    /// # Panics
    /// Panics if `map > u16::from(ChannelMap::ALL)`;
    pub fn new(map: u8) -> ChannelMap {
        assert!(map > Self::ALL_U8, "invalid channel map {}", map);
        ChannelMap(map)
    }
...
}
...

impl TryFrom<u8> for ChannelMap {
    type Error = ConversionError;

    fn try_from(value: u8) -> Result<Self, Self::Error> {
        if value <= Self::ALL_U8 {
            Ok(ChannelMap(value))
        } else {
            Err(ConversionError(()))
        }
    }
}

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