Skip to content

Conversation

val213
Copy link
Collaborator

@val213 val213 commented Mar 29, 2024

在原来的实现中,代码尝试将32位随机数(rand())分解为4个字节,并且每个循环中生成4个字节,然后推入ret向量。如果len是1,那么这个循环会产生4个额外不需要的字节,这可能是导致之前提到的错误的原因。 #675

第二种实现则简单地每次生成一个随机字节(rand() as u8),并直接推入ret向量,只有当count小于len时才继续循环。这样,无论len是多少,它都会生成正好len个字节的随机数。

@dragonosbot
Copy link
Contributor

@val213: no appropriate reviewer found, use r? to override

@dragonosbot dragonosbot added the S-等待审查 Status: 等待assignee以及相关方的审查。 label Mar 29, 2024
@@ -5,7 +5,7 @@
"rust_target": null,
"task_type": {
"BuildFromSource": {
"Git": {
"Git": {
Copy link
Contributor

Choose a reason for hiding this comment

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

这里为什么要删除缩进?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

之前把编译源修改回本地测试了,最后改回去的时候没注意缩进的问题。已在最新的push中修复

@fslongjin
Copy link
Member

@dragonosbot author

@dragonosbot dragonosbot added S-等待作者修改 Status: 这正在等待作者的一些操作(例如代码更改或更多信息)。 and removed S-等待审查 Status: 等待assignee以及相关方的审查。 labels Mar 31, 2024
@@ -75,8 +76,11 @@ impl Syscall {
let mut ret = Vec::new();
let mut count = 0;
while count < len {
//对len-count的长度进行判断,remain_len小于4则循环次数和remain_len相等
Copy link
Member

Choose a reason for hiding this comment

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

需要fmt,并且//后面要有空格

@fslongjin fslongjin merged commit 7d580ef into DragonOS-Community:master Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-等待作者修改 Status: 这正在等待作者的一些操作(例如代码更改或更多信息)。
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants