Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40f54db0 authored by Dominik Laskowski's avatar Dominik Laskowski Committed by Android (Google) Code Review
Browse files

Merge "screencap: Fix parsing of display IDs" into main

parents 6acd07f5 d8dc5b3f
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -142,13 +142,22 @@ int main(int argc, char** argv)
            case 'p':
                png = true;
                break;
            case 'd':
                displayIdOpt = DisplayId::fromValue(atoll(optarg));
            case 'd': {
                errno = 0;
                char* end = nullptr;
                const uint64_t id = strtoull(optarg, &end, 10);
                if (!end || *end != '\0' || errno == ERANGE) {
                    fprintf(stderr, "Invalid display ID: Out of range [0, 2^64).\n");
                    return 1;
                }

                displayIdOpt = DisplayId::fromValue(id);
                if (!displayIdOpt) {
                    fprintf(stderr, "Invalid display ID: %s\n", optarg);
                    fprintf(stderr, "Invalid display ID: Incorrect encoding.\n");
                    return 1;
                }
                break;
            }
            case '?':
            case 'h':
                if (ids.size() == 1) {