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

    +135

    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
    void init(void)
    {
    	int i,j;
    
    	setup();
    	if (!fork())
    		_exit(execve("/bin/update",NULL,NULL));
    	(void) open("/dev/tty0",O_RDWR,0);
    	(void) dup(0);
    	(void) dup(0);
    	printf("%d buffers = %d bytes buffer space\n\r",NR_BUFFERS,
    		NR_BUFFERS*BLOCK_SIZE);
    	printf(" Ok.\n\r");
    	if ((i=fork())<0)
    		printf("Fork failed in init\r\n");
    	else if (!i) {
    		close(0);close(1);close(2);
    		setsid();
    		(void) open("/dev/tty0",O_RDWR,0);
    		(void) dup(0);
    		(void) dup(0);
    		_exit(execve("/bin/sh",argv,envp));
    	}
    	j=wait(&i);
    	printf("child %d died with code %04x\n",j,i);
    	sync();
    	_exit(0);	/* NOTE! _exit, not exit() */
    }

    Говно, вошедшее в историю.

    avaaron, 03 Июня 2010

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

    +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
    for (int x=0; x < TANK_SIZE; x++)
    
    	{
    
    		for (int y=0; y < TANK_SIZE; y++)
    
    		{
    
    			*((Uint32 *)(((Uint8 *)player_surface[DOWN]->pixels) + (TANK_SIZE - y - 1) * player_surface[DOWN]->pitch + (TANK_SIZE - x - 1) * player_surface[DOWN]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)player_surface[LEFT]->pixels) + (TANK_SIZE - x - 1) * player_surface[LEFT]->pitch + y * player_surface[LEFT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)player_surface[RIGHT]->pixels) + x * player_surface[RIGHT]->pitch + (TANK_SIZE - y - 1) * player_surface[RIGHT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)player_surface[UP]->pixels) + y * player_surface[UP]->pitch + x * player_surface[UP]->format->BytesPerPixel));
    
    			*((Uint32 *)(((Uint8 *)enemy_surface[DOWN]->pixels) + (TANK_SIZE - y - 1) * enemy_surface[DOWN]->pitch + (TANK_SIZE - x - 1) * enemy_surface[DOWN]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)enemy_surface[LEFT]->pixels) + (TANK_SIZE - x - 1) * enemy_surface[LEFT]->pitch + y * enemy_surface[LEFT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)enemy_surface[RIGHT]->pixels) + x * enemy_surface[RIGHT]->pitch + (TANK_SIZE - y - 1) * enemy_surface[RIGHT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)enemy_surface[UP]->pixels) + y * enemy_surface[UP]->pitch + x * enemy_surface[UP]->format->BytesPerPixel));
    
    			
    
    		}
    
    	}

    dageru, 03 Июня 2010

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

    +132

    1. 1
    2. 2
    3. 3
    if ((strlen == 0) && (key ==BNS_CLR_K || key ==WISE_K_BSPACE))
    				;
    else

    aljosha, 03 Июня 2010

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

    +130

    1. 1
    2. 2
    3. 3
    #if defined (CAMCORDER_FEATURE_SUPPORT_VIEW_MODE)
    //		case SETTING_VIEW_MODE:	
    #endif

    aljosha, 03 Июня 2010

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

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if(TouchRegist && !gIsCleanView && !gChangeZoom &&!gChangeBrightness)
    			if( TouchRegist && gChangeZoom)
    			{
    				...
    			}	
    			break;

    aljosha, 03 Июня 2010

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

    +103

    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
    /*    Copyright 2009 10gen Inc.
     *
     *    Licensed under the Apache License, Version 2.0 (the "License");
     *    you may not use this file except in compliance with the License.
     *    You may obtain a copy of the License at
     *
     *    http://www.apache.org/licenses/LICENSE-2.0
     *
     *    Unless required by applicable law or agreed to in writing, software
     *    distributed under the License is distributed on an "AS IS" BASIS,
     *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     *    See the License for the specific language governing permissions and
     *    limitations under the License.
     */
    
    /* all the numbers that fit in a 4 byte string */
    const char bson_numstrs[1000][4] = {
        "0",  "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",  "9",
        "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
    	/* 105 строк поскипано */
        "980", "981", "982", "983", "984", "985", "986", "987", "988", "989",
        "990", "991", "992", "993", "994", "995", "996", "997", "998", "999",
    };

    Взято отсюда - http://github.com/mongodb/mongo-c-driver/blob/master/src/numbers.c . А это коммит - http://github.com/mongodb/mongo-c-driver/commit/0198225180a51e0b0b8a84f25b34b3047d3b9c80

    raorn, 02 Июня 2010

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

    +144

    1. 1
    2. 2
    3. 3
    bool somevar;
    //... ... ...
    if(somevar==true)doSomething();

    И это в книге, по которой учат детей.

    frp, 01 Июня 2010

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (nidx == -1) {
      networkIdx = -1;
    } else {
      networkIdx = nidx;
    }

    raorn, 01 Июня 2010

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

    +138

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    -(void)terminateSearchThreadInBackground:(NSNumber*)threadPtr
    {
        NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
        SearchThread* thread = (SearchThread*)[threadPtr unsignedLongValue];
    
        delete thread;
        [pool release];
    }

    И вновь я в шоке от нашего проекта. По какой-то неведомой причине передать в качестве параметра указатель на поток - это очень не трушно. Зато значительно более трушно - создать из него NSNumber, предварительно преобразовав к unsigned long...

    Highlander, 31 Мая 2010

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

    +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
    switch(pin){
    		case 0:
    		break;
    		case 1:
    		ADMUX = 1;
    		case 2:
    		ADMUX = 1 << 1;
    		case 3:
    		ADMUX = 1 | 1 << 1;
    		case 4:
    		ADMUX = 1 << 2;
    		case 5:
    		ADMUX = 1 | 1 << 2;
    		case 6:
    		ADMUX = 1 << 1 | 1 << 2;	
    	}

    Микроконтроллерный говнокод. Этот кусочек указывает, с какого вывода считывать показания АЦП. Эквивалент:
    ADMUX |= pin;

    age, 29 Мая 2010

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