259 if (ret < 0)
260 return ret;
261
262 printk(KERN_ERR"%X\n", reg_val);
259:10: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
if (ret < 0)
^~262:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
printk(KERN_ERR"%X\n", reg_val);
^~~~~~error表示if 是否也包含printk, 将prink和if对齐解决此问题。
1011 sysfs_create_group(&client->dev.kobj, &mt5715_sysfs_group);
1012
1011:5: error: ignoring return value of ‘sysfs_create_group’, declared with attribute warn_unused_result [-Werror=unused-result]
sysfs_create_group(&client->dev.kobj, &mt5715_sysfs_group);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~报错没有使用返回值,修改rc = sysfs_create_group(&client->dev.kobj, &mt5715_sysfs_group);解决报错。
62 #define LOG_INF(fmt, args...) pr_debug(PFX "[%s] " fmt, __func__, ##args)
730 static void capture_setting(kal_uint16 currefps)
731 {
732 LOG_INF("E! currefps:%d\n");
784 static void normal_video_setting(kal_uint16 currefps)
785 {
786 LOG_INF("E! currefps:%d\n");
In function ‘capture_setting’:
kernel-4.4/include/linux/printk.h:33:23: error: format ‘%d’ expects a matching ‘int’ argument [-Werror=format=]#define KLOG_MODNAME ""
^
kernel-4.4/include/linux/printk.h:264:21: note: in definition of macro ‘pr_fmt’
#define pr_fmt(fmt) fmt^~~
kernel-4.4/include/linux/printk.h:422:2: note: in expansion of macro ‘dynamic_pr_debug’
dynamic_pr_debug(KLOG_MODNAME fmt, ##__VA_ARGS__)
^~~~~~~~~~~~~~~~kernel-4.4/include/linux/printk.h:422:19: note: in expansion of macro ‘KLOG_MODNAME’
dynamic_pr_debug(KLOG_MODNAME fmt, ##__VA_ARGS__)
^~~~~~~~~~~~62:31: note: in expansion of macro ‘pr_debug’
#define LOG_INF(fmt, args...) pr_debug(PFX "[%s] " fmt, __func__, ##args)
^~~~~~~~732:2: note: in expansion of macro ‘LOG_INF’
LOG_INF("E! currefps:%d\n");
^~~~~~~In function ‘normal_video_setting’:
kernel-4.4/include/linux/printk.h:33:23: error: format ‘%d’ expects a matching ‘int’ argument [-Werror=format=]
#define KLOG_MODNAME ""
^kernel-4.4/include/linux/printk.h:264:21: note: in definition of macro ‘pr_fmt’
#define pr_fmt(fmt) fmt
^~~kernel-4.4/include/linux/printk.h:422:2: note: in expansion of macro ‘dynamic_pr_debug’
dynamic_pr_debug(KLOG_MODNAME fmt, ##__VA_ARGS__)
^~~~~~~~~~~~~~~~kernel-4.4/include/linux/printk.h:422:19: note: in expansion of macro ‘KLOG_MODNAME’
dynamic_pr_debug(KLOG_MODNAME fmt, ##__VA_ARGS__)
^~~~~~~~~~~~62:31: note: in expansion of macro ‘pr_debug’
#define LOG_INF(fmt, args...) pr_debug(PFX "[%s] " fmt, __func__, ##args)786:2: note: in expansion of macro ‘LOG_INF’
LOG_INF("E! currefps:%d\n");^~~~~~~
第一次看到这种报错,感觉很奇怪,printk.h也报错。我们可以只看C文件的写法,比如line 732, LOG_INF %d没有带有参数,增加打印的参数 LOG_INF("E! currefps:%d\n", currefps);解决报错。
168 printk("moveAF a_u4Position=%u\n",a_u4Position);
210 LOG_INF("move [curr] %u [target] %u\n", g_u4CurrPosition, g_u4TargetPosition);
168:37: error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
printk("moveAF a_u4Position=%u\n",a_u4Position);
^kernel-4.4/include/linux/printk.h:33:23: error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘long unsigned int’ [-Werror=format=]
#define KLOG_MODNAME ""
^kernel-4.4/include/linux/printk.h:264:21: note: in definition of macro ‘pr_fmt’
#define pr_fmt(fmt) fmt
^~~kernel-4.4/include/linux/printk.h:422:2: note: in expansion of macro ‘dynamic_pr_debug’
dynamic_pr_debug(KLOG_MODNAME fmt, ##__VA_ARGS__)
^~~~~~~~~~~~~~~~kernel-4.4/include/linux/printk.h:422:19: note: in expansion of macro ‘KLOG_MODNAME’
dynamic_pr_debug(KLOG_MODNAME fmt, ##__VA_ARGS__)
^~~~~~~~~~~~33:34: note: in expansion of macro ‘pr_debug’
#define LOG_INF(format, args...) pr_debug(AF_DRVNAME " [%s] " format, __func__, ##args)
^~~~~~~~210:3: note: in expansion of macro ‘LOG_INF’
LOG_INF("move [curr] %u [target] %u\n", g_u4CurrPosition, g_u4TargetPosition);
^~~~~~~kernel-4.4/include/linux/printk.h:33:23: error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 5 has type ‘long unsigned int’ [-Werror=format=]
#define KLOG_MODNAME ""
^kernel-4.4/include/linux/printk.h:264:21: note: in definition of macro ‘pr_fmt’
#define pr_fmt(fmt) fmt
^~~kernel-4.4/include/linux/printk.h:422:2: note: in expansion of macro ‘dynamic_pr_debug’
dynamic_pr_debug(KLOG_MODNAME fmt, ##__VA_ARGS__)
^~~~~~~~~~~~~~~~kernel-4.4/include/linux/printk.h:422:19: note: in expansion of macro ‘KLOG_MODNAME’
dynamic_pr_debug(KLOG_MODNAME fmt, ##__VA_ARGS__)
^~~~~~~~~~~~33:34: note: in expansion of macro ‘pr_debug’
#define LOG_INF(format, args...) pr_debug(AF_DRVNAME " [%s] " format, __func__, ##args)
^~~~~~~~210:3: note: in expansion of macro ‘LOG_INF’
LOG_INF("move [curr] %u [target] %u\n", g_u4CurrPosition, g_u4TargetPosition);
^~~~~~~
这里也是报打印的格式不对, format ‘%u’ expects argument of type ‘unsigned int’, but argument 5 has type ‘long unsigned int’,也就是参数是long unsigned int,%u不匹配,修改为%lu解决编译报错。
542 static unsigned int lcm_get_backlight_level()
542:21: error: function declaration isn’t a prototype [-Werror=strict-prototypes]
static unsigned int lcm_get_backlight_level()
^~~~~~~~~~~~~~~~~~~~~~~
这个错误是指声明问题,但是也不知道哪里有问题,对应看了一下 函数定义unsigned int (*backlight_level)(void);,猜测可能是函数形参没写导致的...,将 static unsigned int lcm_get_backlight_level()修改为 static unsigned int lcm_get_backlight_level(void)解决报错。
error: stack frame size of 1648 bytes in function 'VL53L1_print_histogram_bin_data' [-Werror,-Wframe-larger-than=]
这个错误看起是函数占用的堆栈太大导致,参考https://forum.xda-developers.com/showthread.php?t=1748297&page=85,修改CONFIG_FRAME_WARN解决问题。