arduino / arduino/ArduinoCore-API

String object, len is of type unsigned int, however indexOf() and lastIndexOf() return int

Open
#239 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
306
Forks
150
PR merge metrics
No merged PRs in 30d

Description

### Description

String Object:

len is of type unsigned int.
method that apply to position into the String or its size are expecting an unsigned int, this is the case with:
charAt()
substring()
remove()
reserve()

Oddly, indexOf() and lastIndexOf() are returning int and not unsigned int

### Current behavior

Oddly, indexOf() and lastIndexOf() are returning int and not unsigned int

### Expected behavior

indexOf() and lastIndexOf() ought to return unsigned int, to avoid unnecessary casting from int to unsigned int

### Additional information
It's frequent to pass the result of indexOf() to substring()

Thanks

Contributor guide

No contributing guide indexed for this repository

Research direction

Search the ArduinoCore-API String implementation for the indexOf() and lastIndexOf() declarations and implementations, then compare their return types with len, charAt(), substring(), remove(), and reserve(). Verify that both methods consistently use the intended unsigned type and that callers passing their results to substring() no longer require a cast.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.