Skip to content

Add files via upload#1137

Merged
zhblue merged 1 commit intomasterfrom
AI-patch-MiniMax2.7-openclaw
Mar 25, 2026
Merged

Add files via upload#1137
zhblue merged 1 commit intomasterfrom
AI-patch-MiniMax2.7-openclaw

Conversation

@zhblue
Copy link
Copy Markdown
Owner

@zhblue zhblue commented Mar 25, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 25, 2026 02:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds/updates inline documentation comments across judge_client.cc to describe the purpose and behavior of many helper functions used by the judge client.

Changes:

  • Added Chinese /* ... */ function header comments for a large set of existing functions.
  • Documented major judge-client flows (config loading, diff generation, DB/HTTP update routing, runtime setup).
Comments suppressed due to low confidence (4)

trunk/core/judge_client/judge_client.cc:508

  • 这里的注释“原地去除字符串首尾的空白字符”与实现不一致:当前实现会在遇到第一个空白字符时直接截断字符串(而不仅仅是去除尾部空白),并且不会处理尾部连续空白后的内容。建议修正注释以反映“截断到首个空白前”这一行为,或调整实现为真正的 trim(去首尾空白但保留中间空格)。
/* 原地去除字符串首尾的空白字符。 */
void trim(char *c)
{
	char buf[BUFFER_SIZE];
	char *start, *end;

trunk/core/judge_client/judge_client.cc:359

  • execute_cmd 的注释写“返回命令的退出状态”,但当前直接返回 system() 的原始返回值(包含信号/编码信息),并不等同于子进程的 exit code。建议在注释中明确“返回 system() 返回值”,或对返回值用 WIFEXITED/WEXITSTATUS 等进行规范化后再返回。
/* 通过 system(3) 格式化并执行 shell 命令。返回命令的退出状态。 */
int execute_cmd(const char *fmt, ...)   //执行命令获得返回值
{
	char cmd[BUFFER_SIZE];

	int ret = 0;
	va_list ap;

	va_start(ap, fmt);
	vsprintf(cmd, fmt, ap);
	if (DEBUG)
		printf("%s\n", cmd);
	ret = system(cmd);
	va_end(ap);
	if (DEBUG)
		printf("\n");
	return ret;

trunk/core/judge_client/judge_client.cc:804

  • is_str_utf8 的注释表述为“有效的 UTF-8 编码文本”,但实现允许 5/6 字节序列且未校验 overlong/surrogate 等(严格 UTF-8 仅允许 1-4 字节序列)。建议将注释改为“粗略检测/兼容性检测”,或收紧实现以符合严格 UTF-8 校验规则。
/* 检查字节序列是否为有效的 UTF-8 编码文本。 */
bool is_str_utf8(const char* str)
{
  unsigned int nBytes = 0;//UFT8可用1-6个字节编码,ASCII用一个字节
  unsigned char chr = *str;
  bool bAllAscii = true;
  for (unsigned int i = 0; str[i] != '\0'; ++i){

trunk/core/judge_client/judge_client.cc:860

  • fprintSafe 的注释提到“在 HTML/markdown 中安全显示”,但这里并未对 HTML 关键字符(如 <, >, &, ")做转义,更多是为了 Markdown 表格/格式渲染做替换。建议将注释聚焦为“用于 Markdown 表格渲染的字符替换/简易转义”,或补齐 HTML escaping 以匹配注释。
/* 安全地将字符串打印到 FILE 句柄,对特殊字符进行转义或替换以便在 HTML/markdown 中安全显示。 */
inline void fprintSafe(FILE * f,char * buf){
	if(is_str_utf8(buf)){
		str_replace(buf,"|","丨");
		str_replace(buf,"[","[");
		str_replace(buf,"]","]");
		str_replace(buf,"(","(");
		str_replace(buf,")",")");
		str_replace(buf,"*","*");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +241 to 242
/* 使用 fcntl(2) 对指定文件描述符设置排他文件锁。 */
int lockfile(int fd) {
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR 标题是“Add files via upload”,但该变更仅为在 judge_client.cc 中批量补充/调整函数注释(无上传相关逻辑改动)。建议同步更新 PR 标题/描述以匹配实际变更内容,或补充缺失的功能代码。

Copilot uses AI. Check for mistakes.
Comment on lines +274 to 277
/* 打印 ARM64 寄存器值,用于调试系统调用追踪。 */
void print_arm_regs(long long unsigned int *d){
for(int i=0;i<32;i++){
printf("[%d]:%lld ",i,d[i]%CALL_ARRAY_SIZE);
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print_arm_regs 的注释写“打印 ARM64 寄存器值”,但当前输出的是 d[i] % CALL_ARRAY_SIZE(取模后的值),并非寄存器原值;同时 printf 使用 %lld 打印 unsigned long long 也不匹配。建议更正注释(例如说明是“取模后的值/用于 syscall 索引调试”),并将格式化符与类型对齐。

Suggested change
/* 打印 ARM64 寄存器值,用于调试系统调用追踪*/
void print_arm_regs(long long unsigned int *d){
for(int i=0;i<32;i++){
printf("[%d]:%lld ",i,d[i]%CALL_ARRAY_SIZE);
/* 打印 ARM64 寄存器值取模后的结果,用于 syscall 索引调试*/
void print_arm_regs(long long unsigned int *d){
for(int i=0;i<32;i++){
printf("[%d]:%llu ", i, d[i] % CALL_ARRAY_SIZE);

Copilot uses AI. Check for mistakes.
execute_cmd("/bin/rmdir %s/* ", work_dir);
execute_cmd("/bin/rmdir %s/log/* ", work_dir);
}
/* 编译指定语言的提交代码(Main.ext)。成功返回0,失败返回编译错误大小。 */
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compile() 的注释写“成功返回0,失败返回编译错误大小”,但当前实现:对大多数语言直接返回 waitpid 的 status(system 编码/退出码),仅在 lang>3 && lang<7 时才改为返回 ce.txt 文件大小,且 python/js 直接返回0。建议修正注释以匹配实际返回语义,或统一返回值(例如统一为 0=成功,非0=错误,并明确是否为 ce.txt 大小)。

Suggested change
/* 编译指定语言的提交代码(Main.ext)。成功返回0,失败返回编译错误大小。 */
/* 编译指定语言的提交代码(Main.ext)。
* 返回值含义:
* - 一般情况下:0 表示编译成功,非 0 表示编译失败,具体数值为编译器/系统的退出码(waitpid status)。
* - 对某些语言(如 lang>3 && lang<7)编译失败时,可能返回 ce.txt 的大小,用于表示错误信息长度。
* - 对 Python / JavaScript(LANG_PYTHON / LANG_JS):不实际执行编译,始终返回 0,视为“编译通过/准备就绪”。
*/

Copilot uses AI. Check for mistakes.
@zhblue zhblue merged commit 6e15bb9 into master Mar 25, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants