当前位置:网站首页>嵌入式开发:提示和技巧——用C进行防御性编程的最佳实践
嵌入式开发:提示和技巧——用C进行防御性编程的最佳实践
2022-07-28 02:12:00 【粤嵌教育】
最佳实践是每个固件应用程序都应该遵循的基本的、基本的实践。防御性编程一直是一项重要的软件技能。以下是嵌入式开发人员应牢记的一些使用C进行防御性编程的最佳实践:

l 检查功能的输入和输出
l 检查函数的返回值(它们经常被忽略!)
l 监控缓冲区以防止溢出
l 验证指针不为空,尤其是函数指针
l 使用断言宏来检测错误而不是错误条件
l 2–3%的代码应该是断言
l 断言不应该修改系统的状态
l 仅公开大型程序需要知道的数据和函数(封装)
l 在构建过程中执行静态分析
l 监视堆栈是否溢出
l 用已知模式、ISR向量或stop指令填充未使用的ROM
l 看门狗系统应该是综合的,不能盲目宠看门狗
嵌入式开发人员遵循这些简单的最佳实践有助于确保提高固件质量,这是开发安全固件的第一步。
边栏推荐
猜你喜欢

Building of APP automation environment (I)

Superparameter adjustment and experiment - training depth neural network | pytorch series (26)
![[image defogging] image defogging based on dark channel and non-mean filtering with matlab code](/img/39/6266eb14deac9f38b7e95f7291067e.png)
[image defogging] image defogging based on dark channel and non-mean filtering with matlab code

Selenium+pytest+allure comprehensive exercise

【stream】并行流与顺序流

Job 7.27 IO process

【微信小程序开发(六)】绘制音乐播放器环形进度条

On the problem that sqli labs single quotation marks do not report errors

vscode debug显示多列数据

CNN中的混淆矩阵 | PyTorch系列(二十三)
随机推荐
P6118 [JOI 2019 Final]珍しい都市 题解
Data Lake: database data migration tool sqoop
GBase8s如何在有外键关系的表中删除数据
Niuke-top101-bm340
Arm32进行远程调试
[ACNOI2022]总差一步
els 键盘信息
1313_ Pyserial installation and document generation
社恐适合什么工作?能做自媒体吗?
数据中台建设(三):数据中台架构介绍
【微信小程序开发(五)】接口按照根据开发版体验版正式版智能配置
What kind of job is social phobia suitable for? Can you do we media?
JVM 内存布局详解,图文并茂,写得太好了!
Using pytorch's tensorboard visual deep learning indicators | pytorch series (25)
小程序已获取数据库合集中的总记录、用户位置,怎么用Aggregate.geoNear将经纬度由近到远排列?
Collision and rebound of objects in unity (learning)
NPDP考生!7月31号考试要求在这里看!
MySQL essay
[wechat applet development (VI)] draw the circular progress bar of the music player
Opengauss source code, what ide tools are used to manage, edit and debug?