当前位置:网站首页>嵌入式开发:提示和技巧——用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 看门狗系统应该是综合的,不能盲目宠看门狗
嵌入式开发人员遵循这些简单的最佳实践有助于确保提高固件质量,这是开发安全固件的第一步。
边栏推荐
- Explanation of CNN circular training | pytorch series (XXII)
- A brief analysis of the differences between functional testing and non functional testing, recommended by Shanghai haokoubei software testing company
- 【微信小程序开发(六)】绘制音乐播放器环形进度条
- style=“width: ___“ VS width=“___“
- Day 19 of leetcode
- 【stream】并行流与顺序流
- mysql 随笔
- Data center construction (III): introduction to data center architecture
- 数据中台建设(三):数据中台架构介绍
- Why is it that when logging in, you clearly use the account information already in the database, but still display "user does not exist"?
猜你喜欢
![[signal processing] weak signal detection in communication system based on the characteristics of high-order statistics with matlab code](/img/a7/8f0d929457d285adc8020c7f5d33ea.png)
[signal processing] weak signal detection in communication system based on the characteristics of high-order statistics with matlab code
![Trivy [1] tool scanning application](/img/b1/c05949f9379fcde658da64f3a0157a.png)
Trivy [1] tool scanning application

数据湖:海量日志采集引擎Flume

智能工业设计软件公司天洑C轮数亿元融资

四、固态硬盘存储技术的分析(论文)

trivy【1】工具扫描运用

行业洞察 | 语音识别真的超过人耳朵了吗?

Distributed transaction Senta (I)

RTSP/Onvif协议EasyNVR视频平台一键升级方案的开发设计逻辑

Vscode debug displays multiple columns of data
随机推荐
Trivy [1] tool scanning application
CNN循环训练的解释 | PyTorch系列(二十二)
JVM 内存布局详解,图文并茂,写得太好了!
Data center construction (III): introduction to data center architecture
社恐适合什么工作?能做自媒体吗?
[brother hero's July training] day 27: picture
智能工业设计软件公司天洑C轮数亿元融资
tfx airflow 使用体验
LoRaWAN中的网关和chirpstack到底如何通信的?UDP?GRPC?MQTT?
Center-based 3D Object Detection and Tracking(基于中心的3D目标检测和跟踪 / CenterPoint)论文笔记
clientY vs pageY
[stream] parallel stream and sequential stream
What kind of job is social phobia suitable for? Can you do we media?
[email protected]注解使用
为什么登录时,明明使用的是数据库里已经有的账号信息,但依旧显示“用户不存在”?
JS 事件对象 offsetX/Y clientX Y PageX Y
Is it you who are not suitable for learning programming?
clientY vs pageY
【OpenGL】GLES20.glClear
app 自动化 环境搭建(一)