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

    +136

    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
    DIR_STRUCT * fill_dir_struct(DIR_STRUCT * dir_stc, _ptr_by_val_(char *) base_dir_path, _ptr_by_val_(char *) offset_dir)
    {
    	DIR_STRUCT * 		sub_dir;
    	DIR * 				srcdir;
    	struct 				stat st;
    	char 				full_sub_dir_path[MAX_PATH_SIZE];
    	struct dirent * 	dent;
    
    	sprintf(full_sub_dir_path, "%s/%s", base_dir_path, offset_dir);
    	dbgprintln("Directory %s", full_sub_dir_path);
    
    	if(NULL != (dir_stc = malloc(sizeof(DIR_STRUCT))))
    	{
    		memset(dir_stc, 0x00, sizeof(DIR_STRUCT));
    		if (NULL != (srcdir = opendir(full_sub_dir_path)))
    		{
    			if(NULL != (dir_stc->dir_path = malloc(strlen(offset_dir) + 1)))
    			{
    				strcpy(dir_stc->dir_path, offset_dir);
    				for( ;(NULL != (dent = readdir(srcdir))); )
    				{
    					if((0 != strcmp(dent->d_name, ".")) &&
    					   (0 != strcmp(dent->d_name, "..")) &&
    					   (0 <= fstatat(dirfd(srcdir), dent->d_name, &st, 0)))
    					{
    						if (S_ISDIR(st.st_mode)) //Directory
    						{
    							if(NULL != (sub_dir = fill_dir_struct(sub_dir, full_sub_dir_path, dent->d_name)))
    							{
    								dir_stc->sub_dirs 		 	  = list_append_node(dir_stc->sub_dirs, sub_dir);
    								dir_stc->dir_files_size 	 += sub_dir->dir_files_size;
    								dir_stc->sub_dir_files_count += sub_dir->sub_dir_files_count;
    							}
    							else
    							{
    								dir_stc = destroy_dir_struct(dir_stc);
    								break;
    							}
    						}
    						else 					//File
    						{
    							dbgprintln("File %s, size %lu bytes", dent->d_name, st.st_size);
    							dir_stc->dir_files 		 	 = list_append_node(dir_stc->dir_files, allocate_and_copy_char_buffer(dent->d_name, strlen(dent->d_name) + 1));
    							dir_stc->dir_files_size 	+= st.st_size;
    							dir_stc->sub_dir_files_count++;
    						}
    					}
    				}//End of for(;NULL != (dent = readdir(srcdir)); )
    				closedir(srcdir);
    			}
    			else//End of if(NULL != (dir_stc->dir_path = malloc(strlen(offset_dir) + 1)))
    			{
    				dir_stc = destroy_dir_struct(dir_stc);
    			}
    		}//End of if (NULL != (srcdir = opendir(full_sub_dir_path)))
    		else
    		{
    			dir_stc = destroy_dir_struct(dir_stc);
    		}
    	}//End of if(NULL != (dir_stc = malloc(sizeof(DIR_STRUCT))))
    
    	return dir_stc;
    }

    Восьмикратный индент, Йода нотейшн, const *(x) const в аргументах. Есть подозрение, что велосипедисты не знали о scandir.

    Это кладезь говна.

    codemonkey, 08 Октября 2014

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

    +138

    1. 1
    if ((NULL != (string_array = (0 == *length) ? malloc((*length + 1) * REG_SIZE) : realloc(string_array, (*length + 1) * REG_SIZE))))

    А кому-то это говно меинтейнить надо будет...

    codemonkey, 08 Октября 2014

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

    +133

    1. 1
    2. 2
    //str will destroy
    char* strdup_(char* str){

    wat?

    LispGovno, 07 Октября 2014

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

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #define TIME_MATCH    500 /* 5 seconds */
    #define TIMEOUT       2000 /* 20 seconds */
    ...
    if ((pPoint->dwTimer >= TIME_MATCH) 
        || (pPoint->dwTimer >= TIMEOUT)) {
    	    bNewDigit = TRUE;
          }

    И вроде бы причем тут индусы со построчной оплатой кода.

    qxoz, 07 Октября 2014

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

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    SDL_Rect sr = {
    		e->outputRect.x,
    		e->outputRect.y+e->lineHeight*line,
    		e->outputRect.w,
    		sr.y + e->lineHeight };

    laMer007, 06 Октября 2014

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

    +120

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /* Writing: cosine = (double (*)(double)) dlsym(handle, "cos");
           would seem more natural, but the C99 standard leaves
           casting from "void *" to a function pointer undefined.
           The assignment used below is the POSIX.1-2003 (Technical
           Corrigendum 1) workaround; see the Rationale for the
           POSIX specification of dlsym(). */
    
    *(void **) (&cosine) = dlsym(handle, "cos");

    Сишкопроблемы.

    http://linux.die.net/man/3/dlsym

    someone, 28 Сентября 2014

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

    +121

    1. 1
    int main(void)

    GreenKiller, 21 Сентября 2014

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

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    typedef struct tagКАКАЯТОНЕЕБИЧЕСКИДЛИННАЯХУЙНЯ {
        тыц;
        тыц;
        и еще пару раз тыц;
    } КАКАЯТОНЕЕБИЧЕСКИДЛИННАЯХУЙНЯ, *PКАКАЯТОНЕЕБИЧЕСКИДЛИННАЯХУЙНЯ, *LPКАКАЯТОНЕЕБИЧЕСКИДЛИННАЯХУЙНЯ;

    Винстайл такой няшный ^_^

    Pythoner, 21 Сентября 2014

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

    +140

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    //********************************************************************************
    //                                                        (c) корпорация Галактика
    // Галактика 7.12 - Управление производственной логистикой
    // Функции для пересчета в накладных/актах
    //********************************************************************************
    ...
                  ECTb_npux_OPgEP  := False;
                  if (SpSopr.PrMC = word(1))
                  { //--- проверяем только Материалы ---
                    ECTb_PACX_OPgEP  := False;
    ...

    Язык программирования - адская смесь Pascal и С. Но не в этом дело. Я ещё никогда прежде не хотел так сильно надавать по рукам автору названий переменных! Это официальный исходник :(

    st-vincent, 19 Сентября 2014

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

    +131

    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
    /*
     * Copyright (C) 2007-2012 Allwinner Technology Co., Ltd.
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License as
     * published by the Free Software Foundation; either version 2 of
     * the License, or (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program; if not, write to the Free Software
     * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     * MA 02111-1307 USA
     */
    
    #ifndef __DISP_DISPLAY_I_H__
    #define __DISP_DISPLAY_I_H__
    
    #include "ebios_de.h"
    #include "ebios_lcdc_tve.h"
    #include "drv_disp_i.h" /* For DISP_XXXXXX status codes */
    
    #define DE_INF __inf
    #define DE_WRN __wrn
    
    #define OSAL_IRQ_RETURN IRQ_HANDLED
    
    #define HANDTOID(handle)  ((handle) - 100)
    #define IDTOHAND(ID)  ((ID) + 100)
    
    #define INTC_IRQNO_SCALER0  SW_INT_IRQNO_DEFEBE0
    #define INTC_IRQNO_SCALER1  SW_INT_IRQNO_DEFEBE1
    #define INTC_IRQNO_LCDC0    SW_INT_IRQNO_LCDCTRL0
    #define INTC_IRQNO_LCDC1    SW_INT_IRQNO_LCDCTRL1
    
    #define MAX_SPRITE_BLOCKS   32
    
    /*basic data information definition*/
    enum {
    	FALSE = 0,
    	TRUE
    };
    
    #define DIS_NULL 0
    
    #define BIT0    0x00000001
    #define BIT1	0x00000002
    #define BIT2	0x00000004
    #define BIT3	0x00000008
    #define BIT4	0x00000010
    #define BIT5	0x00000020
    #define BIT6	0x00000040
    #define BIT7	0x00000080
    #define BIT8	0x00000100
    #define BIT9	0x00000200
    #define BIT10	0x00000400
    #define BIT11	0x00000800
    #define BIT12	0x00001000
    #define BIT13	0x00002000
    #define BIT14	0x00004000
    #define BIT15	0x00008000
    #define BIT16	0x00010000
    #define BIT17	0x00020000
    #define BIT18	0x00040000
    #define BIT19	0x00080000
    #define BIT20	0x00100000
    #define BIT21	0x00200000
    #define BIT22	0x00400000
    #define BIT23	0x00800000
    #define BIT24	0x01000000
    #define BIT25	0x02000000
    #define BIT26	0x04000000
    #define BIT27	0x08000000
    #define BIT28	0x10000000
    #define BIT29	0x20000000
    #define BIT30	0x40000000
    #define BIT31	0x80000000
    
    
    #endif

    Нашёл в драйвере дисплея. Вместо 1<<N.

    mittorn, 13 Сентября 2014

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