Skip to content

FS position method return valid position on error, should return -1 #9992

Closed
@drmpf

Description

@drmpf

Board

All

Device Description

ESP32
ESP8266 code base has the same issue

Hardware Configuration

all

Version

latest master (checkout manually)

IDE Name

Arduino

Operating System

Windows 10

Flash frequency

40Mhz

PSRAM enabled

yes

Upload speed

115200

Description

Current code returns valid file position on error, should return invalid position, i.e. -1

Current code is

size_t File::position() const {
  if (!*this) {
    return 0;
  }
  return _p->position();
}

should be

size_t File::position() const {
  if (!*this) {
    return -1;  // <<<<<<<<<<<<<<<<
  }
  return _p->position();
}

Sketch

Not needed

Debug Message

None

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions