当前位置: 首页 > news >正文

做企业网站设计与实现凡科建站登录

做企业网站设计与实现,凡科建站登录,健康成都官微最新消息,做介绍自己的短视频网站在阅读和编写内核相关的代码时,经常会看到IS_ERR、ERR_PTR等函数。这些函数在内核头文件的err.h中。以我服务器的代码为例,内核版本为5.15。 这个文件的代码如下: /* SPDX-License-Identifier: GPL-2.0 */ #ifndef _LINUX_ERR_H #define _L…

在阅读和编写内核相关的代码时,经常会看到IS_ERR、ERR_PTR等函数。这些函数在内核头文件的err.h中。以我服务器的代码为例,内核版本为5.15。
在这里插入图片描述
这个文件的代码如下:

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_ERR_H
#define _LINUX_ERR_H#include <linux/compiler.h>
#include <linux/types.h>#include <asm/errno.h>/** Kernel pointers have redundant information, so we can use a* scheme where we can return either an error code or a normal* pointer with the same return value.** This should be a per-architecture thing, to allow different* error and pointer decisions.*/
#define MAX_ERRNO	4095#ifndef __ASSEMBLY__#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)static inline void * __must_check ERR_PTR(long error)
{return (void *) error;
}static inline long __must_check PTR_ERR(__force const void *ptr)
{return (long) ptr;
}static inline bool __must_check IS_ERR(__force const void *ptr)
{return IS_ERR_VALUE((unsigned long)ptr);
}static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
{return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr);
}/*** ERR_CAST - Explicitly cast an error-valued pointer to another pointer type* @ptr: The pointer to cast.** Explicitly cast an error-valued pointer to another pointer type in such a* way as to make it clear that's what's going on.*/
static inline void * __must_check ERR_CAST(__force const void *ptr)
{/* cast away the const */return (void *) ptr;
}static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
{if (IS_ERR(ptr))return PTR_ERR(ptr);elsereturn 0;
}#endif#endif /* _LINUX_ERR_H */

这个文件提供了一套用于处理错误指针的宏和函数。主要部分的解释:

#define MAX_ERRNO 4095:定义了最大的错误号为4095。

#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO):定义了一个宏,用于检查一个值是否在错误号的范围内。

ERR_PTR(long error):这个函数将一个错误号转换为一个错误指针,这样就可以将错误信息通过指针返回。

PTR_ERR(const void *ptr):这个函数将一个错误指针转换回对应的错误号。

IS_ERR(const void *ptr):这个函数检查一个指针是否是错误指针。

IS_ERR_OR_NULL(const void *ptr):这个函数检查一个指针是否是错误指针或者NULL指针。

ERR_CAST(const void *ptr):这个函数将一个错误指针强制转换为另一种类型的指针。

PTR_ERR_OR_ZERO(const void *ptr):这个函数检查一个指针,如果它是错误指针,就返回对应的错误号,否则返回0。

这些函数和宏提供了一种机制,使得函数可以通过返回指针的方式来返回错误信息。

错误号的部分信息在文件errno.h中
代码如下:

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_ERRNO_H
#define _LINUX_ERRNO_H#include <uapi/linux/errno.h>/** These should never be seen by user programs.  To return one of ERESTART** codes, signal_pending() MUST be set.  Note that ptrace can observe these* at syscall exit tracing, but they will never be left for the debugged user* process to see.*/
#define ERESTARTSYS	512
#define ERESTARTNOINTR	513
#define ERESTARTNOHAND	514	/* restart if no handler.. */
#define ENOIOCTLCMD	515	/* No ioctl command */
#define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */
#define EPROBE_DEFER	517	/* Driver requests probe retry */
#define EOPENSTALE	518	/* open found a stale dentry */
#define ENOPARAM	519	/* Parameter not supported *//* Defined for the NFSv3 protocol */
#define EBADHANDLE	521	/* Illegal NFS file handle */
#define ENOTSYNC	522	/* Update synchronization mismatch */
#define EBADCOOKIE	523	/* Cookie is stale */
#define ENOTSUPP	524	/* Operation is not supported */
#define ETOOSMALL	525	/* Buffer or request is too small */
#define ESERVERFAULT	526	/* An untranslatable error occurred */
#define EBADTYPE	527	/* Type not supported by server */
#define EJUKEBOX	528	/* Request initiated, but will not complete before timeout */
#define EIOCBQUEUED	529	/* iocb queued, will get completion event */
#define ERECALLCONFLICT	530	/* conflict with recalled state */
#define ENOGRACE	531	/* NFS file lock reclaim refused */#endif

错误号的部分解释如下

ERESTARTSYS (512):系统调用由于接收到一个可以被处理的信号而被中断,需要被重新启动。

ERESTARTNOINTR (513):系统调用由于某些原因被中断,需要被重新启动,但是不需要检查未决的信号。

ERESTARTNOHAND (514):系统调用由于接收到一个不能被当前进程处理的信号而被中断,需要被重新启动。

ENOIOCTLCMD (515):没有找到对应的ioctl命令。

ERESTART_RESTARTBLOCK (516):系统调用需要被重新启动,但是使用了不同的方法。

EPROBE_DEFER (517):设备驱动程序请求延迟探测。

EOPENSTALE (518):打开操作找到了一个过时的目录项。

ENOPARAM (519):不支持的参数。

EBADHANDLE (521):NFS协议中的非法文件句柄。

ENOTSYNC (522):更新同步不匹配。

EBADCOOKIE (523):Cookie过期。

ENOTSUPP (524):不支持的操作。

ETOOSMALL (525):缓冲区或请求太小。

ESERVERFAULT (526):发生了无法翻译的错误。

EBADTYPE (527):服务器不支持的类型。

EJUKEBOX (528):请求已经启动,但在超时前不会完成。

EIOCBQUEUED (529):iocb已经入队,将会收到完成事件。

ERECALLCONFLICT (530):与被召回的状态冲突。

ENOGRACE (531):NFS文件锁恢复被拒绝。

http://www.ds6.com.cn/news/18551.html

相关文章:

  • wordpress 添加子菜单成都seo的方法
  • 网站前端提成多少免费推广的预期效果
  • 衡水做网站的软件怎么推广
  • 安徽网络优化山西seo和网络推广
  • 网站换域名要怎么做网奇seo赚钱培训
  • 云南网站制作价格百度竞价排名收费
  • 网站建设仟金手指六六14连云港百度推广总代理
  • 自营店网站建设人工智能培训机构排名前十
  • 新建html网站全球网站排名查询网
  • 网站开发语言哪一种好些百度搜索关键词怎么刷上去
  • 石家庄网站开发价格有没有推广app的平台
  • 如何做html网站平面设计培训班学费一般多少
  • python 可以做网站吗网络推广员是什么
  • 网站建设与管理模拟试卷一如何做网站赚钱
  • 凌美上海建设工程网站合肥网站制作公司
  • 做电力项目信息的网站产品宣传方式有哪些
  • pc网站手机网站app青岛官网优化
  • 黑龙江外贸网站制作海外推广方案
  • 网站结构如何优化湛江今日头条新闻
  • 深圳网站制作公司售后2023年8月新冠又来了
  • 炫酷的电商网站设计企业网站搭建
  • 群晖wordpress安装主题下载失败seo的流程是怎么样的
  • 自己做的网站360显示过期百度推广怎么联系
  • 如何建立单页网站建设网站推广
  • 做网站每月收入江门网站建设
  • 杭州做企业网站链接生成器在线制作
  • 成都高端网站建设公司腾讯广告投放推广平台价格
  • 做五金生意什么网站做比较好手机助手
  • 竹子系统做的网站可以优化么完美动力培训价格表
  • 网站宽度980 在ipad上 左对齐了seo搜索排名