Advertisement
f4n

Untitled

f4n
May 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 16.00 KB | None | 0 0
  1. /home/fateyan/dev/tmp/128377_hw4.c:2:1: warning: #includes are not sorted properly [llvm-include-order]
  2. #include <string.h>
  3. ^        ~~~~~~~~~~
  4. /home/fateyan/dev/tmp/128377_hw4.c:6:19: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
  5. void write(char a[5], int b, int c, int d, int e){  //輸出step.txt    傳入char或int?
  6.                   ^
  7. /home/fateyan/dev/tmp/128377_hw4.c:8:28: warning: use 'fopen' mode 'e' to set O_CLOEXEC [android-cloexec-fopen]
  8.     fp1 = fopen("step.txt","w");
  9.                            ^~~
  10.                            "we"
  11. /home/fateyan/dev/tmp/128377_hw4.c:31:5: warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
  12.     int i,j,k;
  13.     ^~~~~~~~~~
  14. /home/fateyan/dev/tmp/128377_hw4.c:44:12: warning: 14 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
  15.     char b[14];
  16.            ^
  17. /home/fateyan/dev/tmp/128377_hw4.c:45:29: warning: use 'fopen' mode 'e' to set O_CLOEXEC [android-cloexec-fopen]
  18.     game = fopen("game.txt","r");
  19.                             ^~~
  20.                             "re"
  21. /home/fateyan/dev/tmp/128377_hw4.c:46:12: warning: 14 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
  22.     char z[14];
  23.            ^
  24. /home/fateyan/dev/tmp/128377_hw4.c:49:18: warning: 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
  25.             if(b[7] == 'B') me = 'b';
  26.                  ^
  27. /home/fateyan/dev/tmp/128377_hw4.c:49:28: warning: statement should be inside braces [google-readability-braces-around-statements]
  28.             if(b[7] == 'B') me = 'b';
  29.                            ^
  30.                             {
  31. /home/fateyan/dev/tmp/128377_hw4.c:50:17: warning: statement should be inside braces [google-readability-braces-around-statements]
  32.             else me = 'y';
  33.                 ^
  34.                  {
  35. /home/fateyan/dev/tmp/128377_hw4.c:53:13: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
  36.             strcpy(z,b);
  37.             ^
  38. /home/fateyan/dev/tmp/128377_hw4.c:53:13: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
  39. /home/fateyan/dev/tmp/128377_hw4.c:59:28: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
  40.                 int t = (b[5]-'0');
  41.                            ^
  42. /home/fateyan/dev/tmp/128377_hw4.c:66:47: warning: statement should be inside braces [google-readability-braces-around-statements]
  43.                         if(size[r][s][i] == 0) continue;
  44.                                               ^
  45.                                                {
  46. /home/fateyan/dev/tmp/128377_hw4.c:67:25: warning: do not use 'else' after 'continue' [readability-else-after-return]
  47.                         else {
  48.                         ^~~~~~
  49. /home/fateyan/dev/tmp/128377_hw4.c:85:28: warning: 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
  50.                 int t = (b[5]-'0');
  51.                            ^
  52. /home/fateyan/dev/tmp/128377_hw4.c:92:47: warning: statement should be inside braces [google-readability-braces-around-statements]
  53.                         if(size[r][s][i] == 0) continue;
  54.                                               ^
  55.                                                {
  56. /home/fateyan/dev/tmp/128377_hw4.c:93:25: warning: do not use 'else' after 'continue' [readability-else-after-return]
  57.                         else {
  58.                         ^~~~~~
  59. /home/fateyan/dev/tmp/128377_hw4.c:112:32: warning: 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
  60.                     myh[2] = b[5]-'0';
  61.                                ^
  62. /home/fateyan/dev/tmp/128377_hw4.c:117:33: warning: 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
  63.                     hish[2] = b[5]-'0';
  64.                                 ^
  65. /home/fateyan/dev/tmp/128377_hw4.c:125:32: warning: 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
  66.                     myh[2] = b[5]-'0';
  67.                                ^
  68. /home/fateyan/dev/tmp/128377_hw4.c:130:33: warning: 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
  69.                     hish[2] = b[5]-'0';
  70.                                 ^
  71. /home/fateyan/dev/tmp/128377_hw4.c:138:12: warning: 14 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
  72.     char a[14]; //我希望a是對方棋子最終位置
  73.            ^
  74. /home/fateyan/dev/tmp/128377_hw4.c:139:27: warning: use 'fopen' mode 'e' to set O_CLOEXEC [android-cloexec-fopen]
  75.     log = fopen("log.txt","r");
  76.                           ^~~
  77.                           "re"
  78. /home/fateyan/dev/tmp/128377_hw4.c:140:16: warning: 5L is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
  79.     fseek(log,-5L,SEEK_END);  //讀最後一排
  80.                ^
  81. /home/fateyan/dev/tmp/128377_hw4.c:143:20: warning: 7L is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
  82.         fseek(log,-7L,SEEK_END);  //最後一步是put
  83.                    ^
  84. /home/fateyan/dev/tmp/128377_hw4.c:152:5: warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
  85.     int m,n,o;
  86.     ^~~~~~~~~~
  87. /home/fateyan/dev/tmp/128377_hw4.c:160:9: warning: Value stored to 'o' is never read [clang-analyzer-deadcode.DeadStores]
  88.         o = (a[5]-'0');
  89.         ^
  90. /home/fateyan/dev/tmp/128377_hw4.c:160:9: note: Value stored to 'o' is never read
  91. /home/fateyan/dev/tmp/128377_hw4.c:160:16: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
  92.         o = (a[5]-'0');
  93.                ^
  94. /home/fateyan/dev/tmp/128377_hw4.c:164:5: warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
  95.     int count1=0,count2=0,count3=0,count4=0;
  96.     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  97. /home/fateyan/dev/tmp/128377_hw4.c:166:34: warning: statement should be inside braces [hicpp-braces-around-statements]
  98.         if(col[m][i][0] == enemy) ++count1;
  99.                                  ^
  100.                                   {
  101. /home/fateyan/dev/tmp/128377_hw4.c:169:34: warning: statement should be inside braces [hicpp-braces-around-statements]
  102.         if(col[i][n][0] == enemy) ++count2;
  103.                                  ^
  104.                                   {
  105. /home/fateyan/dev/tmp/128377_hw4.c:173:38: warning: statement should be inside braces [readability-braces-around-statements]
  106.             if(col[i][i][0] == enemy) ++count3;
  107.                                      ^
  108.                                       {
  109. /home/fateyan/dev/tmp/128377_hw4.c:178:40: warning: statement should be inside braces [hicpp-braces-around-statements]
  110.             if(col[i][3-i][0] == enemy) ++count4;
  111.                                        ^
  112.                                         {
  113. /home/fateyan/dev/tmp/128377_hw4.c:200:60: warning: statement should be inside braces [hicpp-braces-around-statements]
  114.             if(col[m][k][0] == enemy && size[m][k][0] != 4)
  115.                                                            ^
  116.                                                             {
  117. /home/fateyan/dev/tmp/128377_hw4.c:220:60: warning: statement should be inside braces [readability-braces-around-statements]
  118.             if(col[k][n][0] == enemy && size[k][n][0] != 4)
  119.                                                            ^
  120.                                                             {
  121. /home/fateyan/dev/tmp/128377_hw4.c:240:60: warning: statement should be inside braces [readability-braces-around-statements]
  122.             if(col[k][k][0] == enemy && size[k][k][0] != 4)
  123.                                                            ^
  124.                                                             {
  125. /home/fateyan/dev/tmp/128377_hw4.c:260:64: warning: statement should be inside braces [google-readability-braces-around-statements]
  126.             if(col[k][3-k][0] == enemy && size[k][3-k][0] != 4)
  127.                                                                ^
  128.                                                                 {
  129. /home/fateyan/dev/tmp/128377_hw4.c:279:19: warning: 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]
  130.         char temp[10];
  131.                   ^
  132. /home/fateyan/dev/tmp/128377_hw4.c:280:9: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc51-cpp]
  133.         srand(time(0));
  134.         ^
  135. /home/fateyan/dev/tmp/128377_hw4.c:281:12: warning: rand() has limited randomness [cert-msc50-cpp]
  136.         if(rand()%2 == 0){
  137.            ^
  138. /home/fateyan/dev/tmp/128377_hw4.c:282:58: warning: statement should be inside braces [hicpp-braces-around-statements]
  139.             if(myh[0] == 0 && myh[1] == 0 && myh[2] == 0) continue;
  140.                                                          ^
  141.                                                           {
  142. /home/fateyan/dev/tmp/128377_hw4.c:284:16: warning: rand() has limited randomness [cert-msc30-c]
  143.             if(rand()%3 == 0){
  144.                ^
  145. /home/fateyan/dev/tmp/128377_hw4.c:285:32: warning: statement should be inside braces [readability-braces-around-statements]
  146.                 if(myh[0] == 0) continue;
  147.                                ^
  148.                                 {
  149. /home/fateyan/dev/tmp/128377_hw4.c:286:17: warning: do not use 'else' after 'continue' [readability-else-after-return]
  150.                 else {
  151.                 ^~~~~~
  152. /home/fateyan/dev/tmp/128377_hw4.c:287:21: warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
  153.                     int y = rand()%4,z = rand()%4;
  154.                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  155. /home/fateyan/dev/tmp/128377_hw4.c:287:29: warning: rand() has limited randomness [cert-msc30-c]
  156.                     int y = rand()%4,z = rand()%4;
  157.                             ^
  158. /home/fateyan/dev/tmp/128377_hw4.c:287:42: warning: rand() has limited randomness [cert-msc30-c]
  159.                     int y = rand()%4,z = rand()%4;
  160.                                          ^
  161. /home/fateyan/dev/tmp/128377_hw4.c:288:44: warning: statement should be inside braces [readability-braces-around-statements]
  162.                     if(col[y][z][0] != '0') continue;
  163.                                            ^
  164.                                             {
  165. /home/fateyan/dev/tmp/128377_hw4.c:289:21: warning: do not use 'else' after 'continue' [readability-else-after-return]
  166.                     else {
  167.                     ^~~~~~
  168. /home/fateyan/dev/tmp/128377_hw4.c:295:21: warning: rand() has limited randomness [cert-msc30-c]
  169.             else if(rand()%3 == 1){
  170.                     ^
  171. /home/fateyan/dev/tmp/128377_hw4.c:296:32: warning: statement should be inside braces [hicpp-braces-around-statements]
  172.                 if(myh[1] == 0) continue;
  173.                                ^
  174.                                 {
  175. /home/fateyan/dev/tmp/128377_hw4.c:297:17: warning: do not use 'else' after 'continue' [readability-else-after-return]
  176.                 else {
  177.                 ^~~~~~
  178. /home/fateyan/dev/tmp/128377_hw4.c:298:21: warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
  179.                     int y = rand()%4,z = rand()%4;
  180.                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  181. /home/fateyan/dev/tmp/128377_hw4.c:298:29: warning: rand() has limited randomness [cert-msc50-cpp]
  182.                     int y = rand()%4,z = rand()%4;
  183.                             ^
  184. /home/fateyan/dev/tmp/128377_hw4.c:298:42: warning: rand() has limited randomness [cert-msc30-c]
  185.                     int y = rand()%4,z = rand()%4;
  186.                                          ^
  187. /home/fateyan/dev/tmp/128377_hw4.c:299:44: warning: statement should be inside braces [hicpp-braces-around-statements]
  188.                     if(col[y][z][0] != '0') continue;
  189.                                            ^
  190.                                             {
  191. /home/fateyan/dev/tmp/128377_hw4.c:300:21: warning: do not use 'else' after 'continue' [readability-else-after-return]
  192.                     else {
  193.                     ^~~~~~
  194. /home/fateyan/dev/tmp/128377_hw4.c:306:21: warning: rand() has limited randomness [cert-msc30-c]
  195.             else if(rand()%3 == 2){
  196.                     ^
  197. /home/fateyan/dev/tmp/128377_hw4.c:307:32: warning: statement should be inside braces [google-readability-braces-around-statements]
  198.                 if(myh[2] == 0) continue;
  199.                                ^
  200.                                 {
  201. /home/fateyan/dev/tmp/128377_hw4.c:308:17: warning: do not use 'else' after 'continue' [readability-else-after-return]
  202.                 else {
  203.                 ^~~~~~
  204. /home/fateyan/dev/tmp/128377_hw4.c:309:21: warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
  205.                     int y = rand()%4,z = rand()%4;
  206.                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  207. /home/fateyan/dev/tmp/128377_hw4.c:309:29: warning: rand() has limited randomness [cert-msc30-c]
  208.                     int y = rand()%4,z = rand()%4;
  209.                             ^
  210. /home/fateyan/dev/tmp/128377_hw4.c:309:42: warning: rand() has limited randomness [cert-msc30-c]
  211.                     int y = rand()%4,z = rand()%4;
  212.                                          ^
  213. /home/fateyan/dev/tmp/128377_hw4.c:310:44: warning: statement should be inside braces [hicpp-braces-around-statements]
  214.                     if(col[y][z][0] != '0') continue;
  215.                                            ^
  216.                                             {
  217. /home/fateyan/dev/tmp/128377_hw4.c:311:21: warning: do not use 'else' after 'continue' [readability-else-after-return]
  218.                     else {
  219.                     ^~~~~~
  220. /home/fateyan/dev/tmp/128377_hw4.c:320:13: warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
  221.             int w=rand()%4,x=rand()%4,y=rand()%4,z=rand()%4;
  222.             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  223. /home/fateyan/dev/tmp/128377_hw4.c:320:19: warning: rand() has limited randomness [cert-msc30-c]
  224.             int w=rand()%4,x=rand()%4,y=rand()%4,z=rand()%4;
  225.                   ^
  226. /home/fateyan/dev/tmp/128377_hw4.c:320:30: warning: rand() has limited randomness [cert-msc30-c]
  227.             int w=rand()%4,x=rand()%4,y=rand()%4,z=rand()%4;
  228.                              ^
  229. /home/fateyan/dev/tmp/128377_hw4.c:320:41: warning: rand() has limited randomness [cert-msc50-cpp]
  230.             int w=rand()%4,x=rand()%4,y=rand()%4,z=rand()%4;
  231.                                         ^
  232. /home/fateyan/dev/tmp/128377_hw4.c:320:52: warning: rand() has limited randomness [cert-msc30-c]
  233.             int w=rand()%4,x=rand()%4,y=rand()%4,z=rand()%4;
  234.                                                    ^
  235. /home/fateyan/dev/tmp/128377_hw4.c:321:36: warning: statement should be inside braces [hicpp-braces-around-statements]
  236.             if(col[w][x][0] != me ) continue;
  237.                                    ^
  238.                                     {
  239. /home/fateyan/dev/tmp/128377_hw4.c:326:47: warning: statement should be inside braces [hicpp-braces-around-statements]
  240.             if(size[w][x][0] <= size[y][z][0]) continue;
  241.                                               ^
  242.                                                {
  243. Suppressed 78 warnings (78 in non-user code).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement