FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/gpf/osl/os_mem_fl.c @ 475:dcb543907cbb
os_mem_fl.c: os_CreatePartitionPool(): fixed error check logic
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 27 Jun 2014 02:24:27 +0000 |
parents | d26a9e3de626 |
children | 3adb4154f02f |
comparison
equal
deleted
inserted
replaced
474:6e6d4c1ec733 | 475:dcb543907cbb |
---|---|
304 USHORT i, j; | 304 USHORT i, j; |
305 char PoolName[8], *cp; | 305 char PoolName[8], *cp; |
306 | 306 |
307 sts = NU_Obtain_Semaphore(&MemSemCB, NU_SUSPEND); | 307 sts = NU_Obtain_Semaphore(&MemSemCB, NU_SUSPEND); |
308 j = 0; | 308 j = 0; |
309 part_group = 0; | |
310 part_group_head = 0; | 309 part_group_head = 0; |
311 for (i = 0; i <= MaxPoolGroups; i++) { | 310 for (i = 0; i <= MaxPoolGroups; i++) { |
312 if (!PartGrpTable[i].grp_head || !PartGrpTable[i].name[0]) { | 311 if (!PartGrpTable[i].grp_head || !PartGrpTable[i].name[0]) |
313 part_group = i; | 312 break; |
314 break; | |
315 } | |
316 if (!strncmp(GroupName, PartGrpTable[i].name, | 313 if (!strncmp(GroupName, PartGrpTable[i].name, |
317 RESOURCE_NAMELEN - 1)) { | 314 RESOURCE_NAMELEN - 1)) { |
318 part_group_head = PartGrpTable[i].grp_head; | 315 part_group_head = PartGrpTable[i].grp_head; |
319 part_group = i; | |
320 opool = part_group_head; | 316 opool = part_group_head; |
321 j++; | 317 j++; |
322 while (opool->next) { | 318 while (opool->next) { |
323 opool = opool->next; | 319 opool = opool->next; |
324 j++; | 320 j++; |
325 } | 321 } |
326 break; | 322 break; |
327 } | 323 } |
328 } | 324 } |
329 if (part_group > MaxPoolGroups) { | 325 /* |
326 * This error check logic has been modified from the original | |
327 * faithful reconstruction by Space Falcon. In the original code | |
328 * if MaxPoolGroups had been reached and the for loop above | |
329 * never broke, the code would proceed to overwrite pool #0 | |
330 * instead of catching the error. | |
331 */ | |
332 if (i > MaxPoolGroups) { | |
330 release_sem_return_err: | 333 release_sem_return_err: |
331 if (sts == NU_SUCCESS) | 334 if (sts == NU_SUCCESS) |
332 NU_Release_Semaphore(&MemSemCB); | 335 NU_Release_Semaphore(&MemSemCB); |
333 return(OS_ERROR); | 336 return(OS_ERROR); |
334 } | 337 } |
338 part_group = i; | |
335 if (!part_group_head) { | 339 if (!part_group_head) { |
336 strncpy(PartGrpTable[part_group].name, GroupName, | 340 strncpy(PartGrpTable[part_group].name, GroupName, |
337 RESOURCE_NAMELEN); | 341 RESOURCE_NAMELEN); |
338 PartGrpTable[part_group].name[RESOURCE_NAMELEN-1] = 0; | 342 PartGrpTable[part_group].name[RESOURCE_NAMELEN-1] = 0; |
339 } | 343 } |