当前位置:网站首页>嵌入式开发:提示和技巧——用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 看门狗系统应该是综合的,不能盲目宠看门狗
嵌入式开发人员遵循这些简单的最佳实践有助于确保提高固件质量,这是开发安全固件的第一步。
边栏推荐
- [signal processing] weak signal detection in communication system based on the characteristics of high-order statistics with matlab code
- 【stream】stream流基础知识
- 嵌入式分享合集22
- [brother hero's July training] day 26: check the collection
- Es6.--promise, task queue and event cycle
- CNN training cycle reconstruction - hyperparametric test | pytorch series (XXVIII)
- Deep residual learning for image recognition shallow reading and Implementation
- Note that these regions cannot take the NPDP exam in July
- 从硬件编程到软件平台的ci/cd
- MySQL essay
猜你喜欢

Constant power wireless charging based on stm32
[email protected] Annotation usage"/>[email protected] Annotation usage

Record of a cross domain problem
![Trivy [1] tool scanning application](/img/b1/c05949f9379fcde658da64f3a0157a.png)
Trivy [1] tool scanning application

Day 8 of DL
![[stream] basic knowledge of stream](/img/33/0bd85f7e029c81d0c20f463ebb972a.png)
[stream] basic knowledge of stream

Skills in writing English IEEE papers

JS event object 2 e.charcode character code e.keycode key code box moves up, down, left and right

意外收获史诗级分布式资源,从基础到进阶都干货满满,大佬就是强!
![[stream] parallel stream and sequential stream](/img/e1/b8728962c14df56241aa6973c0c706.png)
[stream] parallel stream and sequential stream
随机推荐
牛客-TOP101-BM340
openGauss源代码,用什么IDE工具管理、编辑、调试?
Confusion matrix in CNN | pytorch series (XXIII)
Skills in writing English IEEE papers
Distributed transaction Senta (I)
OA项目之我的审批(会议查询&会议签字)
Using pytorch's tensorboard visual deep learning indicators | pytorch series (25)
Arm32 for remote debugging
@Valid的作用(级联校验)以及常用约束注解的解释说明
Data Lake: database data migration tool sqoop
Retainface use error: modulenotfounderror: no module named'rcnn.cyton.bbox'
Vscode debug displays multiple columns of data
GBase8s如何在有外键关系的表中删除数据
selenium+pytest+allure综合练习
Four methods of modifying MySQL password (suitable for beginners)
What kind of job is social phobia suitable for? Can you do we media?
NPDP考生!7月31号考试要求在这里看!
Data Lake: each module component
Intelligent industrial design software company Tianfu C round financing of hundreds of millions of yuan
社恐适合什么工作?能做自媒体吗?