{"record":{"id":"de6e8c61ae858470","repo":"DrKLO/Telegram","slug":"s-must-name-one-input-and-one-output-file-n-de6e8c","errorCode":null,"errorMessage":"%s: must name one input and one output file\\n","messagePattern":"(.+?): must name one input and one output file\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/wrjpgcom.c","lineNumber":517,"sourceCode":"    /* default input file is stdin */\n#ifdef USE_SETMODE              /* need to hack file mode? */\n    setmode(fileno(stdin), O_BINARY);\n#endif\n#ifdef USE_FDOPEN               /* need to re-open in binary mode? */\n    if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open stdin\\n\", progname);\n      exit(EXIT_FAILURE);\n    }\n#else\n    infile = stdin;\n#endif\n  }\n\n  /* Open the output file. */\n#ifdef TWO_FILE_COMMANDLINE\n  /* Must have explicit output file name */\n  if (argn != argc - 2) {\n    fprintf(stderr, \"%s: must name one input and one output file\\n\", progname);\n    usage();\n  }\n  if ((outfile = fopen(argv[argn + 1], WRITE_BINARY)) == NULL) {\n    fprintf(stderr, \"%s: can't open %s\\n\", progname, argv[argn + 1]);\n    exit(EXIT_FAILURE);\n  }\n#else\n  /* Unix style: expect zero or one file name */\n  if (argn < argc - 1) {\n    fprintf(stderr, \"%s: only one input file\\n\", progname);\n    usage();\n  }\n  /* default output file is stdout */\n#ifdef USE_SETMODE              /* need to hack file mode? */\n  setmode(fileno(stdout), O_BINARY);\n#endif\n#ifdef USE_FDOPEN               /* need to re-open in binary mode? */\n  if ((outfile = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) {","sourceCodeStart":499,"sourceCodeEnd":535,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/wrjpgcom.c#L499-L535","documentation":"Under the TWO_FILE_COMMANDLINE build variant, wrjpgcom requires exactly one input and one output file name. After consuming switches, if argn != argc - 2 (i.e. not exactly two positional args remain), it prints `%s: must name one input and one output file`, calls usage(), and exits. This is a positional-argument-count mismatch.","triggerScenarios":"Running a TWO_FILE_COMMANDLINE build of wrjpgcom with zero, one, or three+ positional file arguments instead of exactly two (input + output).","commonSituations":"Porting a Unix-style invocation (single file, output to stdout) to a Windows/TWO_FILE_COMMANDLINE build, or forgetting the output file argument.","solutions":["Supply exactly two positional paths: input JPEG then output JPEG.","Rebuild mozjpeg without TWO_FILE_COMMANDLINE if stdout-based piping is required.","Check the build's commandline convention (Unix vs two-file) before scripting invocations."],"exampleFix":"// before\nwrjpgcom -comment hi in.jpg\n// after\nwrjpgcom -comment hi in.jpg out.jpg","handlingStrategy":"validation","validationCode":"/* for a TWO_FILE_COMMANDLINE build, require exactly 2 positional args */\nint positional = argc_after_switches;\nif (positional != 2) { /* print expected usage: input AND output */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Know whether the build is Unix-style or TWO_FILE_COMMANDLINE before scripting.","Always supply an explicit output file under TWO_FILE_COMMANDLINE builds.","Document the commandline convention in wrapper scripts."],"tags":["cli","jpeg","mozjpeg","wrjpgcom","arguments","input-validation","build-config"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}