Ignore:
Timestamp:
Feb 14, 2022, 7:57:01 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
ef6d059
Parents:
8761d40a
Message:

Fix argument handling for sink.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/sendfile/consumer.c

    r8761d40a rda81b849  
    3737        case 1: break;
    3838        case 2:
     39                {
     40                        const char * const str = argv[1];
     41                        char* endptr;
     42                        unsigned long long ret = strtoul(str, &endptr, 10);
     43                        if('\0' != *endptr) { fprintf( stderr, "Invalid argument \"%s\" (not a number)\n", str ); goto USAGE;}
     44                        if(errno == ERANGE || ret > 65535)  { fprintf( stderr, "Invalid argument \"%s\" (value too large)\n", str ); goto USAGE;}
     45
     46                        port = ret;
     47                        break;
     48                }
     49        USAGE:
    3950        default:
    40                 fprintf( stderr, "USAGE: %s [port]", argv[0] );
     51                fprintf( stderr, "USAGE: %s [port]\n", argv[0] );
    4152                exit( USAGE_ERROR );
    4253        }
Note: See TracChangeset for help on using the changeset viewer.