1. Си / Говнокод #18535

    +973

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    /* */
            int fooBar() {
                /* do something */
    
    /* - */     return NULL;
    /* + */     return 0ULL;
            }

    > src/foobar.c:42:3: warning: return makes integer from pointer without a cast
    > return NULL;

    П О Ч И Н Е Н О

    #17766

    Elvenfighter, 26 Июля 2015

    Комментарии (12)
  2. Си / Говнокод #18472

    +142

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    int do_execve(const char *filename,
    	const char __user *const __user *__argv,
    	const char __user *const __user *__envp,
    	struct pt_regs *regs)
    {
    	struct user_arg_ptr argv = { .ptr.native = __argv };
    	struct user_arg_ptr envp = { .ptr.native = __envp };
        /* exec mt_debug*/
        int ret;
        int retry = 3;
        do{
            ret = do_execve_common(filename, argv, envp, regs);
            printk(KERN_DEBUG"[exec] %s(%d)\n", filename, retry);
        }while( -999 == ret && retry-- > 0);
    	return ret;
    }

    Ядро от MTK. Они логгируют каждый exec на уровне ядра.

    Azq2, 12 Июля 2015

    Комментарии (4)
  3. Си / Говнокод #18446

    +140

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    int __STRNCMP__(const char s1, const char s2, size_t n)
    {
     for (; n > 0; s1++, s2++, --n)
     if (s1 != s2)
      return (((unsigned char )s1 < (unsigned char )s2) ? -1 : +1);
     else if (*s1 == '\0')
      return 0;
     return 0;
    }

    Зачем нужен такой велосипед?

    Cynicrus, 07 Июля 2015

    Комментарии (6)
  4. Си / Говнокод #18435

    +141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    void perestanovka(int a[13][13], int n, int m){
    	 int maxim, minim, temp,i;
    	
    	 for (i=0; i<n; i++){
             minim=0;
    	 	 for (int j=1; j<m; j++){
     	  	if(a[i][j]<a[i][minim]) minim=j;
       	  }
    	 temp=a[i][0];
         a[i][0]=a[i][minim];
         a[i][minim]=temp;}
    			 
     	  for (int j=0; i<n; i++){
    	  	  maxim=0;
    	 	 for (int j=1; j<m; j++){
    		 	 if(a[i][j]>a[i][maxim]) maxim=j;
    		 }
    		 temp=a[i][m-1];
             a[i][m-1]=a[i][maxim];
    	     a[i][maxim]=temp; }
     }

    lanior, 04 Июля 2015

    Комментарии (6)
  5. Си / Говнокод #18412

    +142

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    #include <stdio.h>
    #include <stdlib.h>
    #include <gb/gb.h>
    #include <gb/drawing.h>
    #include <rand.h>
    #define OBJ_EMPTY 0
    #define OBJ_PLAYER 1
    #define OBJ_ENEMY 2
    
    void clearscr(void);
    void waitbuttona(void);
    void initgame(void);
    void setcubemem(UINT8 formerx,UINT8 formery);
    void enemy(void);
    void wingame(void);
    
    int game_field[5][5];
    int cube_x = 2;
    int cube_y = 3;
    int fcx = 0;
    int fcy = 0;
    UINT8 genenemy = 0;
    UINT8 button;
    int pointx = 0;
    int pointy = 0;
    int i = 0;
    int u = 0;
    
    int main()
    {
     initrand(31415);
     printf("Running Cube");
     waitbuttona();
     clearscr();
     initgame();
     while(1)
     {
      clearscr();
      button = joypad();
      fcx = cube_x;
      fcy = cube_y;
      genenemy = rand();
      if(button == J_UP){ cube_x--; setcubemem(fcx,fcy); }
      if(button == J_DOWN){ cube_x++; setcubemem(fcx,fcy);}
      if(button == J_LEFT){ cube_y--; setcubemem(fcx,fcy);}
      if(button == J_RIGHT){ cube_y++; setcubemem(fcx,fcy);}
      box(cube_y*20,cube_x*20,cube_y*20+10,cube_x*20+10,M_FILL);
      if(genenemy % 4 == 0) enemy();
     }
     return(0);
    }
    
    void clearscr(void)
    {
     color(WHITE,WHITE,SOLID);
     box(0,0,GRAPHICS_WIDTH,GRAPHICS_HEIGHT);
     color(BLACK,WHITE,SOLID);
    }
    
    void waitbuttona(void)
    {
     while(1)
     {
      if(joypad() == J_A) break;
     }
    }
    
    void setcubemem(UINT8 formerx,UINT8 formery)
    {
     game_field[formerx][formery] = 0;
     game_field[cube_x][cube_y] = OBJ_PLAYER;
    }
    
    
    void initgame(void)
    {
     game_field[2][3] = OBJ_PLAYER;
    }
    
    void enemy(void)
    {
      initrand(2);
      game_field[rand()][rand()] = OBJ_ENEMY;
      circle(3*20,1*20,20,1);
      if(game_field[cube_x-2][cube_y-2] == OBJ_ENEMY || game_field[cube_x-1][cube_y-1] == OBJ_ENEMY || game_field[cube_x][cube_y] == OBJ_ENEMY || game_field[cube_x+1][cube_y+1] == OBJ_ENEMY || game_field[cube_x+2][cube_y+2] == OBJ_ENEMY)
      {
       wingame();
      }
    }
    
    
    void wingame(void)
    {
     clearscr();
     gotogxy(40,50);
     gprintf("You've won!");
     delay(1000);
     reset();
    }

    Игра на Gameboy Classic(GBDK,написана мною). Без комментариев.

    fedor2612, 28 Июня 2015

    Комментарии (5)
  6. Си / Говнокод #18363

    +145

    1. 1
    {"Windows 2013", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8.1 and Server 2012 R2 - Added 01/2014 */

    3 вечера ёбли... 20+ собранных ядер во время бисекта и экспериментов...

    А всё из-за пидорасов из acer, которые воткнули в свою прошивку какой-то костыль для windows 8.1, который ломал все свежие ядра линухи (а если не совсем ломал - то не работал тачпад). И из-за пидорасов из других вендоров, которые вынудили линукс прикидываться свежей виндой.

    bormand, 18 Июня 2015

    Комментарии (33)
  7. Си / Говнокод #18293

    +141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    WIN32DLL_DEFINE int _mcrypt_set_key(RI * rinst, byte * key, int nk)
    {				/* blocksize=32*nb bits. Key=32*nk bits */
    	...
    
    	int nb = 8;		/* 256 block size */
    	int i, j, k, m, N;
    	int C1, C2, C3;
    	word32 CipherKey[8];
    
    	nk /= 4;
    
    	...
    
    	rinst->Nb = nb;
    	rinst->Nk = nk;
    
    	...
    
    	if (rinst->Nb < 8) { /* что-что? */
    		...
    	} else {
    		...
    	}
    
    	...
    
    	N = rinst->Nb * (rinst->Nr + 1);
    
    	for (i = j = 0; i < rinst->Nk; i++, j += 4) { /* а вдруг Nk больше 8? */
    		CipherKey[i] = pack(&key[j]);
    	}
    	
    	...
    }

    Реализация блочного симметричного шифрования Rijndael-256 в libmcrypt.
    Прим.: libmcrypt используется как "криптографическое расширение" в PHP.

    denisss025, 08 Июня 2015

    Комментарии (10)
  8. Си / Говнокод #18242

    +143

    1. 1
    fp_env = popen("env", "r");

    не ну я даже не знаю.

    Dummy00001, 27 Мая 2015

    Комментарии (48)
  9. Си / Говнокод #18238

    +140

    1. 1
    2. 2
    3. 3
    4. 4
    /*
     * To the unenlightened: This sets the X (where X is variable between calls) LSB's of mask to 1.
     */
    mask = ~(~0 << X);

    Байтопроблемушки. Me gusta.

    codemonkey, 27 Мая 2015

    Комментарии (5)
  10. Си / Говнокод #18220

    +143

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    /* Example libCello Program */
    
    #include "Cello.h"
    
    int main(int argc, char** argv) {
    
      /* Stack objects are created using "$" */
      var int_item = $(Int, 5);
      var float_item = $(Real, 2.4);
      var string_item = $(String, "Hello");
    
      /* Heap objects are created using "new" */
      var items = new(List, int_item, float_item, string_item);
    
      /* Collections can be looped over */
      foreach (item in items) {
        /* Types are also objects */
        var type = type_of(item);
        print("Object %$ has type %$\n", item, type);
      }
    
      /* Heap objects destroyed with "delete" */
      delete(items); 
    }

    http://libcello.org/

    dxd, 22 Мая 2015

    Комментарии (5)