...
| ! | " | # | $ | % | & | ' | ( | ) | * | + | , | - | . | / | ||
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | : | ; | < | = | > | ? | ||
@ | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | ||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="db05751038f18dd9-38f175b8-49fa40b0-924eb698-4095aaf6b48a2508a446f046"><ac:plain-text-body><![CDATA[ | P | Q | R | S | T | U | V | W | X | Y | Z | [ | \ | ] | ^ | _ | ]]></ac:plain-text-body></ac:structured-macro> |
' | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | ||
p | q | r | s | t | u | v | w | x | y | z | { | | | } | ~ |
...
When naming files, variables, data files etc., it is often best to use only the characters listed above.
Non-Compliant Coding Example
The characters in the file name should be avoided.
Code Block |
---|
#include <fcntl.h>
#include <sys/stat.h>
int main() {
char *file_name = "»£???«";
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
int fd = open(file_name, O_CREAT | O_EXCL | O_WRONLY, mode);
if (fd == -1) {
/* Handle Error */
}
}
|
Compliant Solution
Use a descriptive file name, containing only the subset of ASCII described above.
Code Block |
---|
#include <fcntl.h> #include <sys/stat.h> int main() { char *file_name = "name.ext"; mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; int fd = open(file_name, O_CREAT | O_EXCL | O_WRONLY, mode); if (fd == -1) { /* Handle Error */ } } |
Risk Assessment
This could result in data being lost or misinterpreted during transmission.
...