/* Time bounds setting test
 *		by: john stultz (johnstul@us.ibm.com)
 *		(C) Copyright IBM 2012
 *		Licensed under the GPLv2
 *
 *  NOTE: This is a meta-test which sets the time to edge cases then
 *  uses other tests to detect problems. Thus this test requires that
 *  the inconsistency-check and nanosleep tests be present in the same
 *  directory it is run from.
 *
 *  To build:
 *	$ gcc set-2038.c -o set-2038 -lrt
 *
 *   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.
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#ifdef KTEST
#include "../kselftest.h"
#else
static inline int ksft_exit_pass(void)
{
	exit(0);
}
static inline int ksft_exit_fail(void)
{
	exit(1);
}
#endif

#define NSEC_PER_SEC 1000000000LL

#define KTIME_MAX	((long long)~((unsigned long long)1 << 63))
#define KTIME_SEC_MAX	(KTIME_MAX / NSEC_PER_SEC)

#define YEAR_1901 (-0x7fffffffL)
#define YEAR_1970 1
#define YEAR_2038 0x7fffffffL			/*overflows 32bit time_t */
#define YEAR_2262 KTIME_SEC_MAX			/*overflows 64bit ktime_t */
#define YEAR_MAX  ((long long)((1ULL<<63)-1))	/*overflows 64bit time_t */

int is32bits(void)
{
	return (sizeof(long) == 4);
}

int settime(long long time)
{
	struct timeval now;
	int ret;

	now.tv_sec = (time_t)time;
	now.tv_usec  = 0;

	ret = settimeofday(&now, NULL);

	printf("Setting time to 0x%lx: %d\n", (long)time, ret);
	return ret;
}

int do_tests(void)
{
	int ret;

	ret = system("date");
	ret = system("./inconsistency-check -c 0 -t 20");
	ret |= system("./nanosleep");
	ret |= system("./nsleep-lat");
	return ret;

}

int main(int argc, char *argv[])
{
	int ret = 0;
	int opt, dangerous = 0;
	time_t start;

	/* Process arguments */
	while ((opt = getopt(argc, argv, "d")) != -1) {
		switch (opt) {
		case 'd':
			dangerous = 1;
		}
	}

	start = time(0);

	/* First test that crazy values don't work */
	if (!settime(YEAR_1901)) {
		ret = -1;
		goto out;
	}
	if (!settime(YEAR_MAX)) {
		ret = -1;
		goto out;
	}
	if (!is32bits() && !settime(YEAR_2262)) {
		ret = -1;
		goto out;
	}

	/* Now test behavior near edges */
	settime(YEAR_1970);
	ret = do_tests();
	if (ret)
		goto out;

	settime(YEAR_2038 - 600);
	ret = do_tests();
	if (ret)
		goto out;

	/* The rest of the tests can blowup on 32bit systems */
	if (is32bits() && !dangerous)
		goto out;
	/* Test rollover behavior 32bit edge */
	settime(YEAR_2038 - 10);
	ret = do_tests();
	if (ret)
		goto out;

	settime(YEAR_2262 - 600);
	ret = do_tests();

out:
	/* restore clock */
	settime(start);
	if (ret)
		return ksft_exit_fail();
	return ksft_exit_pass();
}
/net-next.git/log/net?h=nds-private-remove&amp;id=f181d6a3bcc35633facf5f3925699021c13492c5&amp;showmsg=1'>net</a>/<a href='/cgit.cgi/linux/net-next.git/log/net/mac802154?h=nds-private-remove&amp;id=f181d6a3bcc35633facf5f3925699021c13492c5&amp;showmsg=1'>mac802154</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/net/mac802154?h=nds-private-remove&amp;id=f181d6a3bcc35633facf5f3925699021c13492c5'>Collapse</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>
tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><table summary='commit info' class='commit-info'>
<tr><th>author</th><td>Marc Zyngier &lt;marc.zyngier@arm.com&gt;</td><td class='right'>2017-01-17 14:21:56 +0000</td></tr>
<tr><th>committer</th><td>Bjorn Helgaas &lt;bhelgaas@google.com&gt;</td><td class='right'>2017-01-17 08:41:51 -0600</td></tr>
<tr><th>commit</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb/gadget/function/f_obex.c?id=4d191b1b63c209e37bf27938ef365244d3c41084'>4d191b1b63c209e37bf27938ef365244d3c41084</a> (<a href='/cgit.cgi/linux/net-next.git/patch/drivers/usb/gadget/function/f_obex.c?id=4d191b1b63c209e37bf27938ef365244d3c41084'>patch</a>)</td></tr>
<tr><th>tree</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/tree/?id=4d191b1b63c209e37bf27938ef365244d3c41084'>f2ab6cdb65ddacdf2e7c019cd55e353f0c16b400</a> /<a href='/cgit.cgi/linux/net-next.git/tree/drivers/usb/gadget/function/f_obex.c?id=4d191b1b63c209e37bf27938ef365244d3c41084'>drivers/usb/gadget/function/f_obex.c</a></td></tr>
<tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb/gadget/function/f_obex.c?id=51ebfc92b72b4f7dac1ab45683bf56741e454b8c'>51ebfc92b72b4f7dac1ab45683bf56741e454b8c</a> (<a href='/cgit.cgi/linux/net-next.git/diff/drivers/usb/gadget/function/f_obex.c?id=4d191b1b63c209e37bf27938ef365244d3c41084&amp;id2=51ebfc92b72b4f7dac1ab45683bf56741e454b8c'>diff</a>)</td></tr></table>
<div class='commit-subject'>PCI/MSI: pci-xgene-msi: Fix CPU hotplug registration handling</div><div class='commit-msg'>The conversion to the new hotplug state machine introduced a regression
where a successful hotplug registration would be treated as an error,
effectively disabling the MSI driver forever.

Fix it by doing the proper check on the return value.

Fixes: 9c248f8896e6 ("PCI/xgene-msi: Convert to hotplug state machine")
Signed-off-by: Marc Zyngier &lt;marc.zyngier@arm.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Acked-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Tested-by: Duc Dang &lt;dhdang@apm.com&gt;
CC: Thomas Gleixner &lt;tglx@linutronix.de&gt;
CC: stable@vger.kernel.org</div><div class='diffstat-header'><a href='/cgit.cgi/linux/net-next.git/diff/?id=4d191b1b63c209e37bf27938ef365244d3c41084'>Diffstat</a> (limited to 'drivers/usb/gadget/function/f_obex.c')</div><table summary='diffstat' class='diffstat'>