FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[drivers][block] Keep I/O inside the logical partition by manyangshen · Pull Request #11824 · RT-Thread/rt-thread · GitHub

Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 4 additions & 4 deletions components/drivers/block/blk_dev.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ static rt_ssize_t blk_dev_read(rt_device_t dev, rt_off_t sector,
{
struct rt_blk_device *blk = to_blk(dev);

if (sector <= blk->sector_start + blk->sector_count &&
sector_count <= blk->sector_count)
if (sector >= 0 && (rt_size_t)sector <= blk->sector_count &&
sector_count <= blk->sector_count - (rt_size_t)sector)
{
return rt_device_read(&blk->disk->parent,
blk->sector_start + sector, buffer, sector_count);
Expand All @@ -53,8 +53,8 @@ static rt_ssize_t blk_dev_write(rt_device_t dev, rt_off_t sector,
{
struct rt_blk_device *blk = to_blk(dev);

if (sector <= blk->sector_start + blk->sector_count &&
sector_count <= blk->sector_count)
if (sector >= 0 && (rt_size_t)sector <= blk->sector_count &&
sector_count <= blk->sector_count - (rt_size_t)sector)
{
return rt_device_write(&blk->disk->parent,
blk->sector_start + sector, buffer, sector_count);
Expand Down
Loading

Back | FazBrowse Home | New Git URL