Changeset 70221 in vbox
- Timestamp:
- Dec 19, 2017 2:00:01 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119812
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/HostServices/GuestPropertySvc.h
r70108 r70221 164 164 /** 165 165 * Write out flags to a string. 166 *167 166 * @returns IPRT status code 168 * @param fFlags The flags to write out.169 * @param pszFlags Where to write the flags string.170 * @param cbFlags The size of the destination buffer (in bytes).171 */ 172 DECLINLINE(int) GuestPropWriteFlags(uint32_t fFlags, char * pszFlags, size_t cbFlags)167 * @param fFlags the flags to write out 168 * @param pszFlags where to write the flags string. This must point to 169 * a buffer of size (at least) MAX_FLAGS_LEN. 170 */ 171 DECLINLINE(int) GuestPropWriteFlags(uint32_t fFlags, char *pszFlags) 173 172 { 174 173 /* Putting READONLY before the other RDONLY flags keeps the result short. */ … … 180 179 181 180 AssertLogRelReturn(VALID_PTR(pszFlags), VERR_INVALID_POINTER); 182 AssertLogRelReturn(cbFlags, VERR_INVALID_PARAMETER);183 184 pszFlags[0] = '\0';185 186 181 if ((fFlags & ~GUEST_PROP_F_ALLFLAGS) == GUEST_PROP_F_NILFLAG) 187 182 { 183 char *pszNext; 188 184 unsigned i; 189 185 … … 193 189 fFlags |= GUEST_PROP_F_TRANSIENT; 194 190 191 pszNext = pszFlags; 195 192 for (i = 0; i < RT_ELEMENTS(s_aFlagList); ++i) 196 193 { 197 194 if (s_aFlagList[i] == (fFlags & s_aFlagList[i])) 198 195 { 199 rc = RTStrCat(pszFlags, cbFlags, GuestPropFlagName(s_aFlagList[i])); 200 if (RT_FAILURE(rc)) 201 break; 202 196 strcpy(pszNext, GuestPropFlagName(s_aFlagList[i])); 197 pszNext += GuestPropFlagNameLen(s_aFlagList[i]); 203 198 fFlags &= ~s_aFlagList[i]; 204 205 199 if (fFlags != GUEST_PROP_F_NILFLAG) 206 200 { 207 rc = RTStrCat(pszFlags, cbFlags, ", "); 208 if (RT_FAILURE(rc)) 209 break; 201 strcpy(pszNext, ", "); 202 pszNext += 2; 210 203 } 211 204 } 212 205 } 206 *pszNext = '\0'; 213 207 214 208 Assert(fFlags == GUEST_PROP_F_NILFLAG); /* bad s_aFlagList */ -
trunk/src/VBox/HostServices/GuestProperties/service.cpp
r70108 r70221 619 619 { 620 620 char szFlags[GUEST_PROP_MAX_FLAGS_LEN]; 621 rc = GuestPropWriteFlags(pProp->mFlags, szFlags , sizeof(szFlags));621 rc = GuestPropWriteFlags(pProp->mFlags, szFlags); 622 622 if (RT_SUCCESS(rc)) 623 623 { … … 857 857 858 858 char szFlags[GUEST_PROP_MAX_FLAGS_LEN]; 859 int rc = GuestPropWriteFlags(pProp->mFlags, szFlags , sizeof(szFlags));859 int rc = GuestPropWriteFlags(pProp->mFlags, szFlags); 860 860 if (RT_FAILURE(rc)) 861 861 return rc; … … 1016 1016 { 1017 1017 char szFlags[GUEST_PROP_MAX_FLAGS_LEN]; 1018 rc = GuestPropWriteFlags(prop.mFlags, szFlags , sizeof(szFlags));1018 rc = GuestPropWriteFlags(prop.mFlags, szFlags); 1019 1019 if (RT_SUCCESS(rc)) 1020 1020 { … … 1215 1215 /* Send out a host notification */ 1216 1216 const char *pszValue = prop.mValue.c_str(); 1217 rc = GuestPropWriteFlags(prop.mFlags, szFlags , sizeof(szFlags));1217 rc = GuestPropWriteFlags(prop.mFlags, szFlags); 1218 1218 if (RT_SUCCESS(rc)) 1219 1219 rc = notifyHost(pszProperty, pszValue, u64Timestamp, szFlags); … … 1406 1406 1407 1407 char szFlags[GUEST_PROP_MAX_FLAGS_LEN]; 1408 int rc = GuestPropWriteFlags(pProp->mFlags, szFlags , sizeof(szFlags));1408 int rc = GuestPropWriteFlags(pProp->mFlags, szFlags); 1409 1409 if (RT_FAILURE(rc)) 1410 1410 RTStrPrintf(szFlags, sizeof(szFlags), "???"); -
trunk/src/VBox/HostServices/GuestProperties/testcase/tstGuestPropSvc.cpp
r70108 r70221 120 120 if (RT_SUCCESS(rc)) 121 121 { 122 rc = GuestPropWriteFlags(fFlags, pszFlagBuffer , GUEST_PROP_MAX_FLAGS_LEN);122 rc = GuestPropWriteFlags(fFlags, pszFlagBuffer); 123 123 if (RT_FAILURE(rc)) 124 124 RTTestIFailed("Failed to convert flag string '%s' back to a string.", … … 159 159 RTTestISub("Rejection of an invalid flags field"); 160 160 /* This is required to fail. */ 161 if (RT_SUCCESS(GuestPropWriteFlags(u32BadFlags, pszFlagBuffer , GUEST_PROP_MAX_FLAGS_LEN)))161 if (RT_SUCCESS(GuestPropWriteFlags(u32BadFlags, pszFlagBuffer))) 162 162 { 163 163 RTTestIFailed("Flags 0x%x were incorrectly written out as '%.*s'\n", … … 828 828 { 829 829 char szFlags[GUEST_PROP_MAX_FLAGS_LEN]; 830 if (RT_FAILURE(GuestPropWriteFlags(fFlags, szFlags , sizeof(szFlags))))830 if (RT_FAILURE(GuestPropWriteFlags(fFlags, szFlags))) 831 831 RTTestIFailed("Failed to set the global flags."); 832 832 else -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r70130 r70221 5976 5976 { 5977 5977 char szFlags[GUEST_PROP_MAX_FLAGS_LEN]; 5978 if (RT_FAILURE(GuestPropWriteFlags(fFlags, szFlags , sizeof(szFlags))))5978 if (RT_FAILURE(GuestPropWriteFlags(fFlags, szFlags))) 5979 5979 Log(("Failed to set the global flags.\n")); 5980 5980 else -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r70108 r70221 5655 5655 aValue = it->second.strValue; 5656 5656 *aTimestamp = it->second.mTimestamp; 5657 GuestPropWriteFlags(it->second.mFlags, szFlags , sizeof(szFlags));5657 GuestPropWriteFlags(it->second.mFlags, szFlags); 5658 5658 aFlags = Utf8Str(szFlags); 5659 5659 } … … 5937 5937 aValues[i] = it->second.strValue; 5938 5938 aTimestamps[i] = it->second.mTimestamp; 5939 GuestPropWriteFlags(it->second.mFlags, szFlags , sizeof(szFlags));5939 GuestPropWriteFlags(it->second.mFlags, szFlags); 5940 5940 aFlags[i] = Utf8Str(szFlags); 5941 5941 } … … 10453 10453 prop.timestamp = property.mTimestamp; 10454 10454 char szFlags[GUEST_PROP_MAX_FLAGS_LEN + 1]; 10455 GuestPropWriteFlags(property.mFlags, szFlags , sizeof(szFlags));10455 GuestPropWriteFlags(property.mFlags, szFlags); 10456 10456 prop.strFlags = szFlags; 10457 10457 … … 13538 13538 if (it->second.mFlags) 13539 13539 { 13540 GuestPropWriteFlags(it->second.mFlags, szFlags , sizeof(szFlags));13540 GuestPropWriteFlags(it->second.mFlags, szFlags); 13541 13541 aFlags[i] = szFlags; 13542 13542 }
Note:
See TracChangeset
for help on using the changeset viewer.