X-Git-Url: http://ftp.carnet.hr/pub/carnet-debian/scm?a=blobdiff_plain;ds=sidebyside;f=src%2Fshared%2Fmath_op.c;h=202a78523448a6ad6ad512eaecd08f63d54d14e7;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hp=313001351c8286f22360d824a2ead50c30e4c571;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/shared/math_op.c b/src/shared/math_op.c old mode 100755 new mode 100644 index 3130013..202a785 --- a/src/shared/math_op.c +++ b/src/shared/math_op.c @@ -1,63 +1,48 @@ -/* @(#) $Id: math_op.c,v 1.3 2009/06/24 18:53:08 dcid Exp $ */ - /* Copyright (C) 2009 Trend Micro Inc. * All rights reserved. * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public - * License (version 3) as published by the FSF - Free Software + * License (version 2) as published by the FSF - Free Software * Foundation - * - * License details at the LICENSE file included with OSSEC or - * online at: http://www.ossec.net/en/licensing.html */ - #include "shared.h" -/** int os_getprime - * Get the first available prime after the provided value. - * Returns 0 on error. +/* Get the first available prime after the provided value + * Returns 0 on error */ -int os_getprime(int val) +unsigned int os_getprime(unsigned int val) { - int i; - int max_i; - + unsigned int i; + unsigned int max_i; + /* Value can't be even */ - if((val % 2) == 0) - { + if ((val % 2) == 0) { val++; } - - - do - { + + do { /* We just need to check odd numbers up until half - * the size of the provided value. + * the size of the provided value */ i = 3; - max_i = val/2; - while(i <= max_i) - { + max_i = val / 2; + while (i <= max_i) { /* Not prime */ - if((val % i) == 0) - { + if ((val % i) == 0) { break; } i += 2; } /* Prime */ - if(i >= max_i) - { - return(val); + if (i >= max_i) { + return (val); } - }while(val += 2); + } while (val += 2); - return(0); + return (0); } - -/* EOF */