DrKLO/Telegram · warning

Usage: %s [-s] [-r rate2] <file1.sw> <file2.sw>\n

Error message

Usage: %s [-s] [-r rate2] <file1.sw> <file2.sw>\n

What it means

Usage message from opus_compare's main(). Printed when _argc < 3 or _argc > 6 — the wrong number of arguments. Expected: opus_compare [-s] [-r rate2] <file1.sw> <file2.sw>, so 2 to 4 arguments plus the program name.

Source

Thrown at TMessagesProj/jni/opus/src/opus_compare.c:189

  float   *X;
  float   *Y;
  double    err;
  float    Q;
  size_t   xlength;
  size_t   ylength;
  size_t   nframes;
  size_t   xi;
  int      ci;
  int      xj;
  int      bi;
  int      nchannels;
  unsigned rate;
  int      downsample;
  int      ybands;
  int      yfreqs;
  int      max_compare;
  if(_argc<3||_argc>6){
    fprintf(stderr,"Usage: %s [-s] [-r rate2] <file1.sw> <file2.sw>\n",
     _argv[0]);
    return EXIT_FAILURE;
  }
  nchannels=1;
  if(strcmp(_argv[1],"-s")==0){
    nchannels=2;
    _argv++;
  }
  rate=48000;
  ybands=NBANDS;
  yfreqs=NFREQS;
  downsample=1;
  if(strcmp(_argv[1],"-r")==0){
    rate=atoi(_argv[2]);
    if(rate!=8000&&rate!=12000&&rate!=16000&&rate!=24000&&rate!=48000){
      fprintf(stderr,
       "Sampling rate must be 8000, 12000, 16000, 24000, or 48000\n");
      return EXIT_FAILURE;

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Provide exactly two .sw input files as the last arguments.
  2. Use -s before the files for stereo, -r <rate> to set a non-48000 rate; each optional flag adds one arg.
  3. Quote paths correctly so two files stay two arguments.

Example fix

// before
./opus_compare file1.sw

// after
./opus_compare file1.sw file2.sw
# or with options:
./opus_compare -s -r 16000 file1.sw file2.sw
Defensive patterns

Strategy: validation

Validate before calling

// Validate argument count up front.
if (_argc < 3 || _argc > 6) {
    fprintf(stderr, "Usage: %s [-s] [-r rate2] <file1.sw> <file2.sw>\n", _argv[0]);
    return EXIT_FAILURE;
}

Prevention

When it happens

Trigger: _argc not in [3,6]. The two .sw files are mandatory; -s (stereo) and -r rate2 are optional. Fewer than 2 file args or more than 4 total optional+file args triggers it.

Common situations: Comparing only one file; passing extra flags the tool doesn't recognize; quoting errors collapsing multiple paths into one argument; running opus_compare with arguments meant for opusenc/opusdec.

Related errors


AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14). Data as JSON: /api/errors/4773fb76f5b418af. Report an issue: GitHub.