if (srcbloc == NULL) {
fprintf(stderr, "warning!: memrip source is null!\n");
exit(1);
}
if (destbloc == NULL) {
destbloc = malloc(len);
}
if (srcbloc == destbloc) {
fprintf(stderr, "warning!: srcbloc = destbloc\n");
exit(1);
}
if (offset < 0) {
fprintf(stderr, "warning!: offset = %i\n", offset);
}
if (len < 0) {
fprintf(stderr, "warning!: len = %i\n", len);
}
我想知道在运行这个程序时是否会测试所有if语句?
答案 0 :(得分:1)
鉴于你的代码
if (srcbloc == NULL) { /* <-- if this block is entered then, */
fprintf(stderr, "warning!: memrip source is null!\n");
exit(1); /* <-- Program will exit */
}
if (destbloc == NULL) { /* <-- Allocate destbloc of len length. */
destbloc = malloc(len);
}
if (srcbloc == destbloc) { /* <-- if this block is entered then, */
fprintf(stderr, "warning!: srcbloc = destbloc\n");
exit(1); /* <-- Program will exit */
}
if (offset < 0) {
fprintf(stderr, "warning!: offset = %i\n", offset);
}
if (len < 0) {
fprintf(stderr, "warning!: len = %i\n", len);
}
因此,如果(srcbloc == NULL)
或(srcbloc == destbloc)
程序将发出警告(并退出)。如果任何其他测试匹配警告将被打印,但程序将继续处理。