bugfix: 修正潜在的错误路径 (#64)

* bugfix: 修正潜在的错误路径

* 修正格式
This commit is contained in:
login
2022-10-22 20:17:40 +08:00
committed by GitHub
parent ed178b560b
commit d328bfce6b
20 changed files with 269 additions and 188 deletions

View File

@ -108,7 +108,8 @@ static int __check_ui_param(const char *name, const uint8_t type, const struct s
return -EINVAL;
if (ops == NULL)
return -EINVAL;
if (ops->install == NULL || ops->uninstall == NULL || ops->enable == NULL || ops->disable == NULL || ops->change == NULL)
if (ops->install == NULL || ops->uninstall == NULL || ops->enable == NULL || ops->disable == NULL ||
ops->change == NULL)
return -EINVAL;
return 0;
@ -204,6 +205,7 @@ int scm_register(struct scm_ui_framework_t *ui)
*/
int scm_unregister(struct scm_ui_framework_t *ui)
{
return 0;
}
/**
@ -214,6 +216,7 @@ int scm_unregister(struct scm_ui_framework_t *ui)
*/
int scm_unregister_alloc(struct scm_ui_framework_t *ui)
{
return 0;
}
/**
@ -253,19 +256,16 @@ int scm_enable_double_buffer()
return -ENOMEM;
uart_send_str(COM1, "##to change double buffer##\n");
if (ptr->ui_ops->change(buf) != 0) // 这里的change回调函数不会是空指针吗 问题2
if (ptr->ui_ops->change(buf) != 0) // 这里的change回调函数不会是空指针吗 问题2
{
__destroy_buffer(buf);
kfree(buf);
}
}
} while (list_next(&ptr->list) != &scm_framework_list); // 枚举链表的每一个ui框架
// 设置定时刷新的对象
video_set_refresh_target(__current_framework->buf);
// 通知显示驱动,启动双缓冲

View File

@ -1,12 +1,12 @@
//
// Created by longjin on 2022/1/22.
//
#include <common/printk.h>
#include <common/kprint.h>
#include <common/printk.h>
#include <mm/mm.h>
#include <common/spinlock.h>
#include <lib/libUI/textui.h>
#include <mm/mm.h>
#include <common/math.h>
#include <common/string.h>
@ -41,17 +41,19 @@ static int skip_and_atoi(const char **s)
return ans;
}
/**
* 将字符串按照fmt和args中的内容进行格式化然后保存到buf中
* @param buf 结果缓冲区
* @param fmt 格式化字符串
* @param args 内容
* @return 最终字符串的长度
*/
int vsprintf(char *buf, const char *fmt, va_list args)
{
/**
* 将字符串按照fmt和args中的内容进行格式化然后保存到buf中
* @param buf 结果缓冲区
* @param fmt 格式化字符串
* @param args 内容
* @return 最终字符串的长度
*/
// 当需要输出的字符串的指针为空时,使用该字符填充目标字符串的指针
static const char __end_zero_char = '\0';
char *str, *s;
char *str = NULL, *s = NULL;
str = buf;
@ -150,7 +152,7 @@ int vsprintf(char *buf, const char *fmt, va_list args)
precision = va_arg(args, int);
++fmt;
}
else if is_digit (*fmt)
else if (is_digit(*fmt))
{
precision = skip_and_atoi(&fmt);
}
@ -201,7 +203,7 @@ int vsprintf(char *buf, const char *fmt, va_list args)
case 's':
s = va_arg(args, char *);
if (!s)
s = '\0';
s = &__end_zero_char;
len = strlen(s);
if (precision < 0)
{
@ -475,8 +477,8 @@ static char *write_float_point_num(char *str, double num, int field_width, int p
if (sign)
--field_width;
int js_num_z = 0, js_num_d = 0; // 临时数字字符串tmp_num_z tmp_num_d的长度
uint64_t num_z = (uint64_t)(num); // 获取整数部分
int js_num_z = 0, js_num_d = 0; // 临时数字字符串tmp_num_z tmp_num_d的长度
uint64_t num_z = (uint64_t)(num); // 获取整数部分
uint64_t num_decimal = (uint64_t)(round(1.0 * (num - num_z) * pow(10, precision))); // 获取小数部分
if (num == 0 || num_z == 0)