MCPcopy Create free account
hub / github.com/RsyncProject/rsync / poptSaveShort

Function poptSaveShort

popt/popt.c:1018–1044  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1016}
1017
1018int poptSaveShort(short * arg, unsigned int argInfo, long aLong)
1019{
1020 /* XXX Check alignment, may fail on funky platforms. */
1021 if (arg == NULL || (((unsigned long)arg) & (ALIGNOF(*arg)-1)))
1022 return POPT_ERROR_NULLARG;
1023
1024 if (aLong != 0 && LF_ISSET(RANDOM)) {
1025 aLong = (short)poptRandomValue(aLong);
1026 if (aLong < 0)
1027 return aLong;
1028 }
1029 if (LF_ISSET(NOT))
1030 aLong = ~aLong;
1031 switch (LF_ISSET(LOGICALOPS)) {
1032 case 0: *arg = (short) aLong;
1033 break;
1034 case POPT_ARGFLAG_OR: *(unsigned short *)arg |= (unsigned short) aLong;
1035 break;
1036 case POPT_ARGFLAG_AND: *(unsigned short *)arg &= (unsigned short) aLong;
1037 break;
1038 case POPT_ARGFLAG_XOR: *(unsigned short *)arg ^= (unsigned short) aLong;
1039 break;
1040 default: return POPT_ERROR_BADOPERATION;
1041 break;
1042 }
1043 return 0;
1044}
1045
1046/**
1047 * Return argInfo field, handling POPT_ARGFLAG_TOGGLE overrides.

Callers 1

poptSaveArgFunction · 0.85

Calls 1

poptRandomValueFunction · 0.85

Tested by

no test coverage detected